Learn docker in 10 minutes

  • 2020-06-15 10:48:29
  • OfStack

This article takes about 10 minutes.

You will see the following:

Why docker docker several concepts How do I run docker container How build image

This article assumes that you have the following foundations:

1.linux command line (see reference link)

2. Necessary English vocabulary

Why docker?

In discussing the benefits of docker, it is important to understand what docker is. docker's website is described as "Docker is the world's leading container platform". It can be seen that docker is a one-container platform. We put the things we want to pack into one container, and then it can run on docker. Also, docker's container can contain all the dependencies for app to run, so there is no need to manually install all the dependencies once at deployment time.

What are some of the core concepts in docker

Although the first concept is like a textbook, without understanding the core concept, you may not understand the following things... Or skip over here and go straight to the bottom, and come back to it if you don't understand it.

image and container

image is the code that contains 1 application, dependency, runtime. container can be understood as the running form of image, which exists as a separate process.

docker deamon and docker client

docker daemon, back-end service. docker client is a client of docker that interacts with docker deamon.

base image and child image

base image refers to mirrors without parent mirrors, which are usually system-level mirrors, such as ubuntu and alpine. Image of child image built on base image.

Description file for Dockerfile image. It contains all the information needed to run app. This includes base image, code location, working directory, dependencies, project startup commands, and more.

How do I run docker container

The installation of docker will not be described in detail, see the reference link.

First execute your first docker statement

docker container run hello-world

hello world, so cool, right again?

Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 03f4658f8b78: Pull complete a3ed95caeb02: Pull complete Digest: sha256:8be990ef2aeb16dbcb9271ddfe2610fa6658d13f6dfb8bc72074cc1ca36966a7 Status: Downloaded newer image for hello-world:latest

Hello from Docker. This message shows that your installation appears to be working correctly.

If you can see the above, you've run the first docker container, congratulations.

Let's look at what happens when that command runs. First of all, docker will go to your local search for ES122en-ES123en. When it finds no ES127en-ES128en, it will go to docker registry to look for ES127en-ES128en. When it finds it, it will pull it to the local.

Ok, remove the container that is no longer needed. Run the following statement

docker container ls -a

You'll see something down here


CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 
9e354503933b hello-world "/hello" 4 minutes ago Exited (0) 27 seconds ago serene_engelbart

Copy this container id in whole or in part

Running the following statement will remove container

docker container rm -f 9e354503933b

It's not enough to just remove container. container is just the running form. image is still there. Run the following statement to list your local images.

docker images

You will receive and see a corresponding image id and then remove image via image id.

docker image rm 1815c82652c0

How build docker image

That's it for today. I'll talk about it next time.


Related articles: