Podman : Use Dockerfile2022/04/28 |
Use Dockerfile and create Container images automatically.
It is also useful for configuration management for Container images. |
|
[1] | For example, Create a Dockerfile that Nginx is installed and started. |
root@dlp:~#
vi Dockerfile # create new FROM ubuntu MAINTAINER ServerWorld <admin@srv.world> RUN apt-get update RUN apt-get -y install nginx RUN echo "Dockerfile Test on Nginx" > /var/www/html/index.html EXPOSE 80 CMD ["/usr/sbin/nginx", "-g", "daemon off;"] # build image ⇒ podman build -t [image name]:[tag] . root@dlp:~# podman build -t srv.world/ubuntu-nginx:latest . STEP 1/7: FROM ubuntu STEP 2/7: MAINTAINER ServerWorld <admin@srv.world> --> b51cc134aaf STEP 3/7: RUN apt-get update ..... ..... STEP 6/7: EXPOSE 80 --> 1f6e0c4c82f STEP 7/7: CMD ["/usr/sbin/nginx", "-g", "daemon off;"] COMMIT srv.world/ubuntu-nginx:latest --> 00787fa1628 Successfully tagged srv.world/ubuntu-nginx:latest 00787fa1628bc83158413f180fe627d2f438e5f746c8bf00becc95494bd9ab92root@dlp:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/ubuntu-nginx latest 00787fa1628b 52 seconds ago 170 MB srv.world/ubuntu-apache2 latest c5d3a78bc38f 4 minutes ago 224 MB docker.io/library/ubuntu latest 3f4714ee068a 6 days ago 80.3 MB # run container root@dlp:~# podman run -d -p 80:80 srv.world/ubuntu-nginx 2e4306345e393868c78d14316f8ff141c0231868750186bf74c0f48304a79f90root@dlp:~# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 2e4306345e39 srv.world/ubuntu-nginx:latest /usr/sbin/nginx -... 6 seconds ago Up 6 seconds ago 0.0.0.0:80->80/tcp modest_wilbur # verify accesses root@dlp:~# curl localhost Dockerfile Test on Nginx # also possible to access via container network root@dlp:~# podman inspect -l | grep \"IPAddress "IPAddress": "10.88.0.8", "IPAddress": "10.88.0.8",root@dlp:~# curl 10.88.0.8 Dockerfile Test on Nginx |
The format of Dockerfile is [INSTRUCTION arguments] . Refer to the following description for INSTRUCTION.
|
Sponsored Link |
|