Podman : Use Dockerfile2024/05/05 |
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> --> f2fc42956ea5 STEP 3/7: RUN apt-get update ..... ..... STEP 6/7: EXPOSE 80 --> 79117f75b19a STEP 7/7: CMD ["/usr/sbin/nginx", "-g", "daemon off;"] COMMIT srv.world/ubuntu-nginx:latest --> 1b1a4d3f4f26 Successfully tagged srv.world/ubuntu-nginx:latest 1b1a4d3f4f26fdac6a7556c81a8cee65bfdbaaeff204ccc700f16b91d83e8decroot@dlp:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/ubuntu-nginx latest 1b1a4d3f4f26 About a minute ago 125 MB srv.world/ubuntu-apache2 latest 38d508336863 37 minutes ago 226 MB docker.io/library/ubuntu latest bf3dc08bfed0 5 days ago 78.7 MB # run container root@dlp:~# podman run -d -p 80:80 --security-opt apparmor=unconfined srv.world/ubuntu-nginx 1628817a1fa315f96be582e324daf4fad31bc51f1ef015be6dd3f2d2750fb5fdroot@dlp:~# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 1628817a1fa3 srv.world/ubuntu-nginx:latest /usr/sbin/nginx -... 18 seconds ago Up 18 seconds 0.0.0.0:80->80/tcp intelligent_chatterjee # 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.2", "IPAddress": "10.88.0.2",root@dlp:~# curl 10.88.0.2 Dockerfile Test on Nginx |
The format of Dockerfile is [INSTRUCTION arguments] . Refer to the following description for INSTRUCTION.
|
Sponsored Link |