0% found this document useful (0 votes)
10 views

Dockerfile

Uploaded by

santhosh G
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Dockerfile

Uploaded by

santhosh G
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

v A Dockerfile is a simple text file with instructions to build an image.

v If we do not have the docker file, to build the image and run the container word by word
we used the command line interface according to our requirements.

v But this docker file helps us to provide the instruction on what needs to be pulled, what
arguments need to be run after building the image, and providing some configurations.
FROM

Use the FROM instruction to specify the base image for your container. Here’s an example using the official
Ubuntu image as the base:

LABEL:

Add metadata to your image using the LABEL instruction. It’s useful for providing information about the image,
such as the maintainer or version:
RUN:

Execute shell commands during the image build process. Use RUN to install software or set up the container
environment. For example:

COPY:

Copy files and directories from the host system into the container image. Here’s how you can copy a local HTML
file into the container:
ADD:

Similar to COPY, but more versatile. It can download files from URLs and extract compressed archives. For example:

WORKDIR:

Set the working directory for subsequent instructions. Any relative paths specified will be relative to this directory. For
instance:

ENV:

Define environment variables within the container image. These variables can be used in subsequent instructions and
during container runtime:
EXPOSE:

Document the ports on which the container listens for incoming connections (for documentation purposes):

CMD:

Specify the default command to run when a container is started. Override it by providing a command when running the
container:

ENTRYPOINT:

Define an executable that always runs, making it harder to override. Useful for the primary application process:
VOLUME:

Create a mount point for a volume, which persists data outside the container. Useful for storing database files or
logs:

USER:

Set the user or UID for the instructions that follow, improving container security:

HEALTHCHECK:

Define a command to check the health of the container, used by orchestration platforms to monitor container
health:

You might also like