Dockerfile and container images
Building container images using a Dockerfile.
Here areHere's a few Dockerfile examples.
- that
Aruns a simplecontainernmap.to scan a network
Dockerfile
# Start with a base image
FROM redhat/ubi8
# Maintainer information
MAINTAINERLABEL ClusterAppsorg.opencontainers.image.authors="mail@clusterapps.com"
<mail@clusterapps.com>LABEL description="Simple Network scan"
# Run commands to build the container
# Do as much with the fewest RUN lines
RUN yumdnf --assumeyesy update && \
yumdnf --assumeyesy install \
nmap iproute procps-ng && \
bash && \
yumdnf 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.
MAINTAINERLABEL
GeneralInstruction contactadds informationmetadata aboutto thean 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.
Build, tag run
Build with a tag.
podman build -t nmap:latest .
Run the image with the built in CMD.
podman run nmap
Run with different CMD
podman run nmap -sT -Pn -p80 192.168.252.210