Debian 13 trixie

Podman : Use Dockerfile2025/08/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 debian
LABEL 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/debian-nginx:latest .

STEP 1/7: FROM debian
STEP 2/7: LABEL Maintainer "ServerWorld <admin@srv.world>"
--> b297213dbe62
STEP 3/7: RUN apt-get update

.....
.....

COMMIT srv.world/debian-nginx:latest
--> 33b7b5b10b13
Successfully tagged srv.world/debian-nginx:latest
33b7b5b10b139dea3a74317cc07172214360a6df956f4799b84dfb3e8b1b2cc0

root@dlp:~#
podman images

REPOSITORY                TAG         IMAGE ID      CREATED             SIZE
srv.world/debian-nginx    latest      33b7b5b10b13  About a minute ago  157 MB
srv.world/debian-apache2  latest      a0aca892bf29  8 minutes ago       234 MB
docker.io/library/debian  latest      047bd8d81940  11 days ago         124 MB

# run container

root@dlp:~#
podman run -d -p 80:80 srv.world/debian-nginx

05470306188d35c1a6367f585d5f8656c041fe88ca2ec50f2cc7db4588d23691

root@dlp:~#
podman ps

CONTAINER ID  IMAGE                          COMMAND               CREATED        STATUS        PORTS               NAMES
05470306188d  srv.world/debian-nginx:latest  /usr/sbin/nginx -...  9 seconds ago  Up 9 seconds  0.0.0.0:80->80/tcp  exciting_noyce

# 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.15",
                         "IPAddress": "10.88.0.15",

root@dlp:~#
curl 10.88.0.15

Dockerfile Test on Nginx
The format of Dockerfile is [INSTRUCTION arguments] .
Refer to the following description for INSTRUCTION.
INSTRUCTION Description
FROM It sets the Base Image for subsequent instructions.
RUN It will execute any commands when Docker image will be created.
CMD It will execute any commands when Docker container will be executed.
ENTRYPOINT It will execute any commands when Docker container will be executed.
LABEL It adds metadata to an image.
EXPOSE It informs Docker that the container will listen on the specified network ports at runtime.
ENV It sets the environment variable.
ADD It copies new files, directories or remote file URLs.
COPY It copies new files or directories.
The differences of [ADD] are that it's impossible to specify remote URL and also it will not extract archive files automatically.
VOLUME It creates a mount point with the specified name and marks it as holding externally mounted volumes from native host or other containers.
USER It sets the user name or UID.
WORKDIR It sets the working directory.

Matched Content