Podman : Use Dockerfile2021/03/22 |
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:stream8 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 ⇒ docker build -t [image name]:[tag] . [root@dlp ~]# podman build -t srv.world/centos-nginx:latest . STEP 1: FROM centos:stream8 STEP 2: MAINTAINER ServerWorld <admin@srv.world> --> ebbbd7990da STEP 3: RUN dnf -y install nginx ..... ..... STEP 6: CMD ["/usr/sbin/nginx", "-g", "daemon off;"] STEP 7: COMMIT srv.world/centos-nginx:latest --> 857fd2f5a02 857fd2f5a02678346c1d2da28f11b25c396679d0fafc621b6bb2800e9a7b5d48[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/centos-nginx latest 857fd2f5a026 About a minute ago 298 MB srv.world/centos-httpd latest 6a4b6e2cae37 17 minutes ago 322 MB registry.centos.org/centos stream8 2f3766df23b6 3 months ago 217 MB # run container [root@dlp ~]# podman run -d -p 80:80 srv.world/centos-nginx bb1f145aa93b8f65a8e88c04ddefe5a215876b03f365d40499cff28d7e620740[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES bb1f145aa93b srv.world/centos-nginx /usr/sbin/nginx -... 11 seconds ago Up 11 seconds ago 0.0.0.0:80->80/tcp nervous_shirley # 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.17", "IPAddress": "10.88.0.17",[root@dlp ~]# curl 10.88.0.17 Dockerfile Test on Nginx |
The format of Dockerfile is [INSTRUCTION arguments] . Refer to the following description for INSTRUCTION.
|
Sponsored Link |
|