Podman : Use Dockerfile2025/04/22 |
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 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> --> e49d0cbab6b1 STEP 3/7: RUN apt-get update ..... ..... STEP 7/7: CMD ["/usr/sbin/nginx", "-g", "daemon off;"] COMMIT srv.world/ubuntu-nginx:latest --> 1fbf2477f02c Successfully tagged srv.world/ubuntu-nginx:latest 1fbf2477f02cd01968a529fc12d5b01f95367a533117b0ef57851514080956earoot@dlp:~# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/ubuntu-nginx latest 1fbf2477f02c 58 seconds ago 137 MB srv.world/ubuntu-apache2 latest b7f1351d1b3c 8 minutes ago 246 MB docker.io/library/ubuntu latest 602eb6fb314b 13 days ago 80.6 MB # run container root@dlp:~# podman run -d -p 80:80 srv.world/ubuntu-nginx 092dcbb88514700160d12b9fb514d3f4d0861aaa6eae505b5c59a2f3a3c7eb92root@dlp:~# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 092dcbb88514 srv.world/ubuntu-nginx:latest /usr/sbin/nginx -... 9 seconds ago Up 10 seconds 0.0.0.0:80->80/tcp nervous_blackwell # 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 |