Podman : Use Dockerfile2022/03/14 |
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 centos:stream9 MAINTAINER ServerWorld <admin@srv.world> RUN dnf -y install nginx RUN echo "Dockerfile Test on Nginx" > /usr/share/nginx/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/centos-nginx:latest . STEP 1/6: FROM centos:stream9 STEP 2/6: MAINTAINER ServerWorld <admin@srv.world> --> 10096b868a1 STEP 3/6: RUN dnf -y install nginx ..... ..... STEP 5/6: EXPOSE 80 --> 6b26f04ed36 STEP 6/6: CMD ["/usr/sbin/nginx", "-g", "daemon off;"] COMMIT srv.world/centos-nginx:latest --> 762eb0a249a Successfully tagged srv.world/centos-nginx:latest 762eb0a249a51c7e9fbc1c524207011bba773f7757e6140cdd4aa19eec8f83cf[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/centos-nginx latest 762eb0a249a5 26 seconds ago 247 MB srv.world/centos-httpd latest 0c6c507d6e95 7 minutes ago 253 MB quay.io/centos/centos stream9 44ffcc4acee8 3 days ago 152 MB # run container [root@dlp ~]# podman run -d -p 80:80 srv.world/centos-nginx 42707c810650c3b7f717226c3e827fdba913514341856993e746aaec698f3652[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 42707c810650 srv.world/centos-nginx:latest /usr/sbin/nginx -... 7 seconds ago Up 8 seconds ago 0.0.0.0:80->80/tcp stoic_boyd # 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.13", "IPAddress": "10.88.0.13",[root@dlp ~]# curl 10.88.0.13 Dockerfile Test on Nginx |
The format of Dockerfile is [INSTRUCTION arguments] . Refer to the following description for INSTRUCTION.
|
Sponsored Link |
|