Podman : Use Dockerfile2025/04/25 |
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 fedora 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/fedora-nginx:latest . STEP 1/6: FROM fedora STEP 2/6: MAINTAINER ServerWorld <admin@srv.world> --> 8ba0796d094e STEP 3/6: RUN dnf -y install nginx ..... ..... Successfully tagged srv.world/fedora-nginx:latest ad26e76247bd7a02a9ee54a7579c8971255f766a49b211bc7f3ea8a6a2b9b171[root@dlp ~]# podman images REPOSITORY TAG IMAGE ID CREATED SIZE srv.world/fedora-nginx latest ad26e76247bd 31 seconds ago 325 MB srv.world/fedora-httpd latest 512d39041a55 8 minutes ago 328 MB registry.fedoraproject.org/fedora latest e5bf03515e92 22 hours ago 166 MB # run container [root@dlp ~]# podman run -d -p 80:80 srv.world/fedora-nginx 110ee53f0546342c437c65b5b8167fef0912f7010787b621f2380fdf15a704d2[root@dlp ~]# podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 110ee53f0546 srv.world/fedora-nginx:latest /usr/sbin/nginx -... 5 minutes ago Up 5 minutes 0.0.0.0:80->80/tcp adoring_gauss # 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.10", "IPAddress": "10.88.0.6",[root@dlp ~]# curl 10.88.0.6 Dockerfile Test on Nginx |
The format of Dockerfile is [INSTRUCTION arguments] . Refer to the following description for INSTRUCTION.
|
Sponsored Link |
|