Skip to main content

Dockerfile and container images

Building container images using a Dockerfile.

Here are a few Dockerfile examples.

  1. A simple container to scan a network
# Start with a base image
FROM redhat/ubi8
# Maintainer information
MAINTAINER ClusterApps <mail@clusterapps.com>

# Run commands to build the container
# Do as much with the fewest RUN lines
RUN yum --assumeyes update && \
yum --assumeyes install \
nmap iproute procps-ng && \
bash && \
yum clean all

# Entrypoint is the command that run when the ccontainer starts
ENTRYPOINT ["/usr/bin/nmap"]
#  The arguments for the entrypoint
CMD ["-sn", "192.168.252.0/24"]

What to know about the file:

  • FROM

The FROM is the base used for the new image.

  • MAINTAINER

General contact information about the image builder.

  • RUN

The run command is that steps taken to build the image. Each RUN command will build an additional layer to the image. It is best to use the fewest RUN entries as possible.

  • ENTRYPOINT

This is the what the container will run when it first starts. This might be a binary or a script that starts jobs or services.

  • CMD

These are the arguments to the ENTRYPOINT. The CMD can be overwritten on the command line.