Documentation DockerFile
Documentation DockerFile
Introduction
What are dockerfiles?
Dockerfile is a small program with easy to understand syntax to create a Docker image. It
includes all the required dependencies and components to run an application.
The command to build the dockerfile is:
docker build –t image-name . The dot specifies the current location
The -t is used for tagging the image. The dot specifies the current location. If the dockerfile is in
a different location, the path of the dockerfile has to be mentioned.
The Docker Workflow resolves “works on my machine” issue by setting up the development
environment across all other environments without any hassle.
Dockerfile Format
A dockerfile must start with FROM statement. It must include either CMD or ENTRYPOINT. The
other statements are optional and depends on the application.
2. Type the content as shown below to create an image. Busybox is a simple image with
command line utility. The RUN command will be executed while building the image. The
CMD statement will be executed after launching the container.
3. To run the dockerfile, type the command “docker build –t image-name .”.
4. To view the created image, type the command “docker images”. The created image
“hello” is listed in the image list.
5. To build container from the image, type “docker run --rm image-name”. The --rm tag is
used to clean up the container after its usage.
b) Download Ubuntu image
1. Start by creating a file named Dockerfile. Type the contents as shown below. The FROM
statement downloads Ubuntu as the base OS for the container. The RUN statement
updates the packages of the image and install nano. The CMD command opens the
notes file using the nano command. The CMD command is represented in EXEC form.
2. After building the image, the created image “notes” will be displayed in the image list. To
run the image, type the command “docker run --rm –ti image-name”. The tag –ti is used
for the interactive terminal. By running the image, the container is created and the notes
file (/tmp/notes) is opened.
References:
[1]"Docker explained in simple terms!!", Medium, 2020. [Online]. Available: https://medium.com/dev-
genius/docker-explained-in-simple-terms-
178748e28e99#:~:text=A%20Dockerfile%20is%20a%20text,on%20that%20in%20a%20moment).
[Accessed: 22- Dec- 2020].