Podman : Use Dockerfile2024/02/28 |
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:~ # podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/freebsd-httpd latest add46dedb2b7 6 hours ago 1.44 GB localhost/freebsd-base latest 2527bfa5eeb4 26 hours ago 1.05 GB quay.io/centos/centos stream9 ce3ac91d4020 2 weeks ago 161 MB docker.io/library/ubuntu latest 3db8720ecbf5 2 weeks ago 80.4 MB
root@dlp:~ #
vi Dockerfile # create new FROM localhost/freebsd-base MAINTAINER ServerWorld <admin@srv.world> RUN pkg install -y nginx RUN echo "Dockerfile Test on Nginx" > /usr/local/www/nginx/index.html EXPOSE 80 CMD ["/usr/local/sbin/nginx", "-g", "daemon off;"] # build image ⇒ podman build -t [image name]:[tag] . root@dlp:~ # podman build -t localhost/freebsd-nginx:latest ./ STEP 1/6: FROM localhost/freebsd-base STEP 2/6: MAINTAINER ServerWorld <admin@srv.world> --> 94a83aae8186 STEP 3/6: RUN pkg install -y nginx ..... ..... Successfully tagged localhost/freebsd-nginx:latest a0a053cc78a36337f6d2ed5d91b03faca848c90ef957d3574246bc804a7a7be3root@dlp:~ # podman images REPOSITORY TAG IMAGE ID CREATED SIZE localhost/freebsd-nginx latest a0a053cc78a3 13 seconds ago 1.17 GB localhost/freebsd-httpd latest add46dedb2b7 6 hours ago 1.44 GB localhost/freebsd-base latest 2527bfa5eeb4 26 hours ago 1.05 GB quay.io/centos/centos stream9 ce3ac91d4020 2 weeks ago 161 MB docker.io/library/ubuntu latest 3db8720ecbf5 2 weeks ago 80.4 MB # run container root@dlp:~ # podman run -d -p 80:80 freebsd-nginx 26508ff7f0d95d58c16e055fc15be1701535299c51258356f893e0c6ed0ef296root@dlp:~ # podman ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 26508ff7f0d9 localhost/freebsd-nginx:latest /usr/local/sbin/n... 8 seconds ago Up 7 seconds 0.0.0.0:80->80/tcp boring_newton # verify to access to nginx from any remote host root@dlp:~ # ssh freebsd@node01.srv.world "curl -s http://`hostname`" (freebsd@node01.srv.world) Password for freebsd@node01.srv.world: Dockerfile Test on Nginx # to access from localhost, specify container IP address directly root@dlp:~ # podman exec 26508ff7f0d9 /sbin/ifconfig eth0 | grep inet inet 10.88.0.5 netmask 0xffff0000 broadcast 10.88.255.255root@dlp:~ # curl 10.88.0.5 Dockerfile Test on Nginx |
The format of Dockerfile is [INSTRUCTION arguments] . Refer to the following description for INSTRUCTION.
|
Sponsored Link |