Sponsored Link

Podman : Use Dockerfile2021/07/29

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

MAINTAINER ServerWorld <>

RUN dnf -y install nginx
RUN echo "Dockerfile Test on Nginx" > /usr/share/nginx/html/index.html

CMD ["/usr/sbin/nginx", "-g", "daemon off;"]

# build image ⇒ docker build -t [image name]:[tag] .

[root@dlp ~]#
podman build -t .

STEP 2: MAINTAINER ServerWorld <>
--> 32cbb164a44
STEP 3: RUN dnf -y install nginx


STEP 6: CMD ["/usr/sbin/nginx", "-g", "daemon off;"]
--> 35c58055062

[root@dlp ~]#
podman images

REPOSITORY                       TAG     IMAGE ID      CREATED         SIZE            latest  35c580550628  23 seconds ago  340 MB            latest  bb62279be7bd  9 minutes ago   342 MB  latest  333da17614b6  5 weeks ago     234 MB

# run container

[root@dlp ~]#
podman run -d -p 80:80


[root@dlp ~]#
podman ps

CONTAINER ID  IMAGE                  COMMAND               CREATED        STATUS            PORTS               NAMES
5d6a1232d35a  /usr/sbin/nginx -...  6 seconds ago  Up 7 seconds ago>80/tcp  goofy_wilbur

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

[root@dlp ~]#

Dockerfile Test on Nginx
The format of Dockerfile is [INSTRUCTION arguments] .
Refer to the following description for INSTRUCTION.
FROM iIt sets the Base Image for subsequent instructions.
MAINTAINER It sets the Author field of the generated images.
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 remore 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