Podman : Use Dockerfile2025/01/21 |
Use Dockerfile and create Container images automatically. |
|
[1] | For example, Create a Dockerfile that Nginx is installed and started. |
[root@dlp ~]#
vi Dockerfile # create new FROM quay.io/centos/centos:stream10 LABEL 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 quay.io/centos/centos:stream10 STEP 2/6: LABEL Maintainer "ServerWorld <admin@srv.world>" --> f56fe93572b6 STEP 3/6: RUN dnf -y install nginx ..... ..... STEP 5/6: EXPOSE 80 --> a359719d7431 STEP 6/6: CMD ["/usr/sbin/nginx", "-g", "daemon off;"] COMMIT srv.world/centos-nginx:latest --> 451cd94e6c28 Successfully tagged srv.world/centos-nginx:latest 451cd94e6c28ad9a8c31bf9ebec39a200c2fa9f6ae4eb9119b28f48bfdedf424[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/centos-nginx latest d64d577f9a9e 46 minutes ago 347 MB srv.world/centos-httpd latest ff3843182253 About an hour ago 354 MB quay.io/centos/centos stream10 1ef274445e32 7 days ago 311 MB # run container [root@dlp ~]# podman run -d -p 80:80 srv.world/centos-nginx 925839be591b3e8cf1d776eb77e289cd6a8fc2cca757dfbe37d8e5b6ef0dd5a5[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 925839be591b srv.world/centos-nginx:latest /usr/sbin/nginx -... 12 seconds ago Up 13 seconds 0.0.0.0:80->80/tcp agitated_engelbart # line 98 : change to [no] StrictForwardPorts= no
[root@dlp ~]#
systemctl restart firewalld
# 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 |
|