Member-only story

Building Docker explained (101)

Park Sehun
3 min readAug 5, 2023

Dockerfile is a text document that contains all the commands a user could call on the command line to assemble an image.

When you have Docker built, Docker will read your Dockerfile, and then the activity output will be the Docker Image.

The syntax of Dockerfile is straightforward…

# comment
INSTRUCTION arguments

# INSTRUCTIONs: FROM, RUN, CMD, LABEL, EXPOSE, ENV, ADD, COPY, ENTRYPOINT, VOLUME, USER

However, A docker file must start with a FROM instruction as the FROM instruction specifies the Base Image from which you are building.

Let’s make the Docker story!

Case: you need the nginx server with the super simple index file.

When you are installing on a Linux server, what you will do is

  1. Get the Linux server (ubuntu)
  2. Update the install tool: apt-get update
  3. Of course, you will install nginx: apt-get install -y nginx
  4. Then, I will go to the /var/www folder and edit the index file: echo “My modification to the index file” > /var/www/html/index.nginx-debian.html
  5. Lastly, make sure my nginx engine is running: nginx -g ‘daemon off;’

Now, let’s rewrite your Dockerfile

# Get the Linux server
FROM ubuntu

# Update the install tool
RUN apt-get update

# install nginx
RUN apt-get install -y nginx…

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

No responses yet

Write a response