[Docker] – Understanding Docker Images

They are nothing more than a text file called Dockerfile with the instructions which are required to build a container. Then, each instruction is called a Layer. Following an exemplification.

Example:

FROM ubuntu:18.04
COPY . /app
RUN make /app
CMD python /app/app.py

See what it is doing:

    • FROM the ubuntu:18.04 means from where it will start. The ubuntu:18.04 is a Docker image of the Ubuntu SO and 18.04 is its tag/version of it.
    • Then, COPY and RUN are instructions to copy all from the current dir to /app and execute the command line $ make /app.
    • Note that the last instruction is the CMD which means that it will be the command executed when the container be initialized to run the application.

 

image-layers-docker

NOTES:

  • See here the docker images commands
  • See here a repository with many examples of Dockerfile images

Perform the following exercise to learn how to create it.

https://www.katacoda.com/courses/docker/2

Also, please feel free to check the tag docker of this website to see all related blog posts.

Sponsored by:

Logo-horizontalCP Logo Big - vertical invert (1)

1 Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s