One 、 System environment planning

Server name

Project name

docker

operating system

CentOS Linux release 7.1.1503 (Core)

Docker edition

17.03.2-ce

 

Two 、Docker brief introduction

Docker A container can be simply understood as a lightweight virtual machine , Containers are isolated from each other . There is isolation on the operating system between virtual machines and virtual machines , And between containers is process isolation .

Use Docker It can bring us great convenience , such as : You can create multiple containers on a single host , Use as multiple nodes ; Install multiple... On one machine MySQL example , Their ports are 3306; We can package our applications and so on .

Docker Official homepage : https://www.docker.com

Docker Official documents : https://docs.docker.com/

Docker Hub: https://hub.docker.com

 

3、 ... and 、Docker Installation

Docker Running on the CentOS 7 On , The system is required to be 64 position 、 The kernel version of the system is 3.10 above .Docker Running on the CentOS-6.5 Or later CentOS On , The system is required to be 64 position 、 The kernel version of the system is 2.6.32-431 Or higher CentOS 7 In general, the kernel of is 3.10 Of , and CentOS 6.X In general, the kernel of is 2.6, stay 2.6 Under the core of ,Docker Running will be more card , So you usually choose to upgrade to 3.10 edition .

 

3.1、 Uninstall the old version of the system docker

yum remove -y docker docker-client docker-client-latest docker-common \

docker-latest docker-latest-logrotate docker-logrotate \

docker-selinux docker-engine-selinux docker-engine

3.2、 Install related dependency packages :

install docker You may report errors, missing packages, or low version of dependent packages , Install or upgrade dependent packages as appropriate .

yum install -y yum-utils device-mapper-persistent-data lvm2

3.3、 To configure docker Source

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

3.4、 install docker

Before installation, we can check which ones are available docker edition

yum list docker-ce --showduplicates | sort -r

install docker: So here's what we installed 17.03.2 edition .

yum install -y --setopt=obsoletes=0 docker-ce-17.03.2.ce-1.el7.centos.x86_64 \

docker-ce-selinux-17.03.2.ce-1.el7.centos.noarch

3.5、 We can also use the official script to install docker

curl -fsSL get.docker.com -o get-docker.sh

sh get-docker.sh

Four 、 see Docker Version and related information

4.1、 installation is complete , see docker Version information

4.2、 start-up docker

installed docker The service is not started , Service start required .

systemctl enable docker

systemctl start docker

To start over , see docker Service status :

4.3、docker info see docker Related information

5、 ... and 、 Pull the image to create the container

Image( Mirror image ) and Container( Containers ) yes Docker Two basic concepts in .

Here Image It can be understood as the operating system image needed to create a virtual machine , in other words Image It's the image needed to create the container .

We need to pull images from the Internet : This is a centos 7.6 Mirror image

docker pull centos:7.6.1810

Pull over , View downloaded images :

With the image, we can use the image to create the container .

Of course, images of other versions can also be downloaded

download 7.8 Mirror image

[root@docker ~]# docker pull centos:7.8.2003

7.8.2003: Pulling from library/centos

9b4ebb48de8d: Pull complete

Digest: sha256:8540a199ad51c6b7b51492fa9fee27549fd11b3bb913e888ab2ccf77cbb72cc1

Status: Downloaded newer image for centos:7.8.2003

6、 ... and 、 Create a container

6.1、 We use docker ps perhaps docker ps -a Command to view all the container information , as follows , There are currently no containers , So let's create one .

docker run -d --name centos7_6_01 -h container_01 \

-p 220:22 \

--privileged=true \

centos:7.6.1810 /usr/sbin/init

Parameter interpretation :

--name centos7_6_01   Name the container :centos7_6_01

-h container_01 For containers hostname:container_01

-p 220:22    For will 22 Port maps to 220, That is to say, you can use 220 The port connects directly to this container

centos:7.6.1810 Choose which image to use to create the container

Creation completed ,docker ps Check out the current container :

Here we see a NAMES by centos7_6_01 The container .

There are two ways to get into a container , as follows :

docker exec -it  <NAMES>  bash

docker exec -it  <CONTAINER ID>  bash

That is, you can directly use the container name or container ID To enter

docker exec -it centos7_6_01 bash

docker exec -it ed20ee9b8226 bash

6.2、 Each container has its own IP Of ,IP You can specify... At creation time , It can also automatically generate .

6.3、 Modify container time :

After the container is created , The internal time is inconsistent with the host operating system , Need modification .

On the host operating system :

docker cp /usr/share/zoneinfo/Asia/Shanghai centos7_6_01:/etc/localtime

After modification, enter the container again :

7、 ... and 、 Submit a container as an image template

Docker You can submit a container as a image, In other words, we can use a container as a template to create or copy a container , This can provide us with great convenience , Save more time .

such as : We are centos7_6_01 It's installed in the container MySQL Database and related configuration , We also need to create a container with the same environment and configuration centos7_6_02, So we're going to create an empty container first , Then go and install MySQL Database and other configuration information , Or just put centos7_6_01 As a template, copy a container directly ? Of course, it's faster and more efficient to copy one directly .

View the current container and image information as follows , We put name by centos7_6_01 The container is submitted as a template for our subsequent use , It can also be said that centos7_6_01 Replication to achieve an automated deployment function .

We put the container centos7_6_01 Submitted as centos7_6  Version is 2.0 A mirror image of :

docker commit centos7_6_01 centos7_6:2.0

Let's create a container with the newly created image : Create a file called mysql_01, The host name is mysql_01, Port is 221 The container of :

docker run -d --name mysql_01 -h mysql_01 \

-p 221:22  \

--privileged=true \

centos7_6:2.0 /usr/sbin/init

At this point we created mysql_01  The container is just like centos7_6_01 The containers are exactly the same .

Containers mysql_01  Have an independent ip Address .

DOCKER Installation steps - More articles about the most reliable notes

  1. Docker Application deployment record ( Include perfection Docker Installation steps )

    Docker Application deployment record ( Include perfection Docker Installation steps ) Preface First of all, let's talk about the source of this article . The one I took over before IOT project , Multiple central control servers need to be installed . The central control server needs to be installed RabbitMQ,Mysql, Multiple services , ...

  2. ubuntu In the environment docker Installation steps

    This article is based on docker Translation of official documents , original text :https://docs.docker.com/engine/installation/linux/ubuntulinux/ Docker Support the following Ubun ...

  3. Docker Installation steps

    I'm learning springcloud Message bus , Need to install rabbitmq, because rabbitmq Yes, it is erlang Developed , So install rabbitmq You need to install it first erlang, All in all, there are various pits in the installation process , But in the end ...

  4. windows docker install cloudera/quickstart

    I need to write a big data project recently , But the company doesn't have a test environment , It's cao egg , Can't , You can only build your own test environment , So I installed one on my local computer cloudera/quickstart, This is a single node big data platform , yes clo ...

  5. Docker The road to installation

    from 3 From the beginning of this month to now , I've been installing docker The road is farther and farther , It's about 1 An hour ago , I finally succeeded , That moment , I feel like I have the whole world , So , Having the whole world, I decided to make a cursory record of what I can remember during the installation process ...

  6. 【Linux】【 Self study notes 】Linux below docker install mysql

    Write it at the front : Keep going , Before I put one SpringBoot The program is installed in docker above , Reference link :https://www.cnblogs.com/aki-stones/p/2019-11-01-note.h ...

  7. mac Under the system docker Installation configuration mysql The detailed steps

    As described above MacOS install Docker Stupid tutorial , After installation, the first thing to do is to migrate the local database , So first you have to install mysql, Let's start our installation journey . One .docker Configure image Accelerator We use docke ...

  8. docker install mysql、es、jenkins And how to set up docker Domestic mirror

    CentOS7 install Docker step : (0) Remove old packages that may have been installed yum remove docker \                   docker-client \              ...

  9. Docker Desktop for Windows Installation steps

    Docker Desktop for Windows Installation requirements Docker Desktop for Windows Need to run Microsoft Hyper-V. if necessary ,Docker Desktop ...

  10. MongoDB Study note 2 : Use Docker install MongoDB

    Catalog Docker install MongoDB Docker to MongoDB Set user password NoSQL Manager for MongoDB Connect by admin Grant authority The last note introduced Windows Lower installation Mong ...

Random recommendation

  1. Write your own from scratch C# frame (15)——Web Layer back end login function

    For a backend management system , One of the most important contents is the landing page , Whether it's security verification . Users record online . Related logging . Single user or multi-user account control, etc , It's all processed on this page . 1. Create a... In the solution Web project , And set it up ...

  2. Mongodb Study note 1 (Mongodb Environment configuration )

    Mongodb Study explain : MongoDB from databases form ,database from collections form ,collection from documents form ,document from fileds form .Mo ...

  3. Nginx Reverse proxy multi host proxy

    according to http://www.cnblogs.com/zzzhfo/p/6032095.html This environment configuration stay web01 and web02 Configure a domain name based virtual host on the web01 [root@web01 /]# ...

  4. Socket Socket

    TCP/IP(Transmission Control Protocol/Internet Protocol) Transmission control protocol / Internet Protocol , It's an industry standard protocol set , It's for the wan (WANs) The design of the .UDP( ...

  5. lua Three characteristics of language

    pack and unpack For a function , To convert its input parameter to a table , be pack The function is right . For a table, convert it to The input parameter of a function , be lua Provided by the native unpack Functions can be implemented . do arrayDa ...

  6. For javascript Programming

    Define objects as constructors function Person(name, age) { this.name = name; this.age = age; this.sayName = function ...

  7. iOS Development : In depth understanding of GCD Second articles (dispatch_group、dispatch_barrier、 Multi read single write based on thread safety )

    Dispatch Group In addition to Dispatch Queue I want to finish processing after several tasks in , This kind of demand will appear frequently . If you just use one Serial Dispatch Queue( Serial queue ) when , only ...

  8. linux Next system timing task configuration ----crontab(mysql Scheduled backup )

    crontab Commands are used to set the instructions that are executed periodically , And windows The next planned task is similar to , When the operating system is installed , This service tool is installed by default , And it will start automatically crond process ,crond The process periodically checks every minute to see if there are any tasks to execute ...

  9. eclipse Use the folder as sourcefolder

    Folder --- Right click

  10. Excel Data import to Dataset in

    public static DataSet ExcelToDataSet(string ppfilenameurl,string pptable) { string strConn = "P ...