This is the 14th day of my participation in the August Text Challenge.More challenges in August

How do I use Docker

1. Three core concepts of Docker
  • The mirror
  • The container
  • warehouse

Let’s take another example: we build a house in a vacant lot, we carry bricks, we carry wood, and then we build the house in one go; Two years later, the government came to demolish. How to do?

We had to go somewhere else to build the house, and at this point, as before, I had to move the bricks again, move the wood again, and then put the house up again; But this time, a man named

The beautiful boy of Docker taught me a spell. With this spell, I can pack the house I built into a mirror image and put it in my backpack until I arrive at another empty space

Ground, use this mirror image, build the house directly, carry the original package to move in.

In the above example, the image in the bag is the Docker image, the backpack is the Docker warehouse, and the house built with the image is the Docker container. This container is who we are

So this container is where the program runs

Second, the mirror
docker imagesCommand to view local mirrors
[root@VM-0-17-centos ~]# Docker images REPOSITORY TAG IMAGE ID CREATED SIZE Ubuntu 14.04 13b66b487594 4 months ago 197MB Redis RC-AlPINE3.12 5BCA63D382F8 8 months ago 32.3MB Redis latest EF47f3b6dc11 8 months ago 104MB mysql 5.7 Ef08065b0a30 11 months ago 448MB ubuntu 15.10 9b9cb95443b5 5 years ago 452 MBCopy the code

Description of each option:

  • REPOSITORY: represents the REPOSITORY source of the image
  • TAG: indicates the TAG of the mirror
  • IMAGE ID: indicates the ID of an IMAGE
  • CREATED: indicates the time when a mirror is CREATED
  • SIZE: indicates the mirror SIZE

    A REPOSITORY can have multiple tags that represent different versions of the REPOSITORY. For example, ubuntu REPOSITORY has multiple versions 14.04, 15.10, etc. We use REPOSITORY:TAG to define different images.

[root@VM-0-17-centos ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 43b022f0dc1b Ubuntu :14.04 "/bin/bash" 11 minutes ago Exited (127) About a minute ago beautiful_ishizaka 5dc5b452764a Ubuntu :15.10 "/bin/bash" 14 12 Minutes ago Exited (130) 12 minutes ago Strangers with supper supper -- Twos 0617a905d18F Redis: RC-Alpine3.12 "Docker-entryPoint.s..." 16 minutes ago Exited (0) 16 minutes ago Elated_nash 4edCA6117751 Redis: RC-AlPINE3.12 "Docker-entryPoint.s..." 17 minutes ago Exited (127) 16 minutes ago Musing_hopper 8f55fbd844e1 Redis "Docker-entryPoint.s..." 17 minutes ago Exited (127) 16 minutes ago Musing_hopper 8f55fbd844e1 redis "Docker-entryPoint.s..." 4 months ago Up 4 months 0.0.0.0:6379->6379/ TCP redis_wd 4969aaf7caa2 redis "docker-entrypoint.s..." 7 Months ago Exited (137) 4 months ago redis-API c8c15320bd4d Redis "docker-entrypoint.s..." 7 months ago Exited (137) 7 months ago Redis-test 08be69defCBD mysql:5.7 "Docker-entrypoint.s..." 10 months ago Up 2 months 33060/tcp, 0.0.0.0:3309->3306/ TCP mysql_57 [root@VM-0-17-centos ~]# docker rm 43b022f0dc1b 5dC5b452764a 43b022f0dc1b 5dC5b452764aCopy the code

Build the mirror

In addition to being pulled from a public repository, images can also be built locally from scratch; We use the command docker build to create a new image from scratch;

docker build -f /path/to/a/Dockerfile
Copy the code

The -f flag points to a Dockerfile anywhere in the file system. Dockerfile file can be found on Baidu to write, I will also open a separate article to write

After the image construction is completed, upload it to the Docker warehouse, and then docker pull it down on another machine to realize the environment migration.

The next article will continue with the Docker container.