I. Introduction to Docker

The official website link: www.docker.com

Docker is an open source application container engine that allows developers to package their applications and dependencies into a portable image that can then be distributed to any popular Linux or Windows machine, as well as virtualization. Containers are completely sandboxed and have no interface with each other.

The relationship between an Image and a Container is similar to that between a class and an instance in object-oriented programming. An Image is a static definition and a Container is an entity of the Image runtime. Docker containers are created by Docker images.

Two, system requirements

The current installation system is CentOS 7Copy the code

Docker installation

1. Install Docker

Website tutorial docs.docker.com/engine/inst Docker setup…

Install the yum-utils package (which provides the yum-config-manager utility) and set up the stable repository. sudo yum install -y yum-utils sudo yum-config-manager \ --add-repo \ Ali cloud source address https://download.docker.com/linux/centos/docker-ce.repo or use sudo yum - config - manager \ - add - repo \ http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo (2). Sudo yum install docker-ce docker-ce cli containerd.io Install the latest version of DOCKER Engine and container: sudo yum install docker-ce docker-ce cli containerd.ioCopy the code

2. Check the Docker version

docker -v

docker version
Copy the code

3. Start Docker

systemctl start docker
Copy the code

4. Check the Docker status

systemctl status docker
Copy the code

5. Restart Docker

systemctl restart docker
Copy the code

6. Stop Docker

systemctl stop docker
Copy the code

7, set the boot from the start

systemctl enable docker
Copy the code

8. Do not start the machine

systemctl disable docker
Copy the code

9. List all mirrors

docker images
Copy the code

10. Delete the mirror

docker rmi IMAGE_ID
Copy the code

11. View all containers

docker ps
Copy the code

12. Start a container

Docker start Specifies the container nameCopy the code

13. Stop a container

Docker stop container nameCopy the code

Exit a container

exit
Copy the code

15. Delete a container

Docker RM Container IDCopy the code

Uninstall old Docker

sudo yum remove docker \ docker-client \ docker-client-latest \ docker-common \ docker-latest \ docker-latest-logrotate Docker-logrotate docker-engine or use the following method to list the related packages docker installed: Sudo yum list installed | grep docker delete the relevant installation package sudo yum - y remove docker - ce. X86_64 sudo yum - y remove Sudo rm -rf /var/lib/docker sudo yum remove docker docker-common docker-selinux docker-engineCopy the code

17. Docker run parameter Description

Docker run [OPTIONS] IMAGE [COMMAND] [ARG…]

OPTIONS are described as follows:

-a stdin: specifies the standard input and output types. The options are stdin, STDOUT, or STDERR. -d: Runs the container in the background and returns the container ID. -i: Runs the container in interactive mode, usually with -t. -p: specifies the port mapping. The format is as follows: Host (host) port: container port -t: reassigns a pseudo input terminal to the container. It is usually used together with -i. --name="nginx-lb": specify a name for the container; -- DNS 8.8.8.8: Specifies the DNS server used by the container. The default DNS server is the same as the host server. --dns-search example.com: specify the container DNS search domain name, which is the same as the host by default. -h "Mars ": specifies the hostname of the container. -e username=" Ritchie ": Set the environment variable. --env-file=[]: reads environment variables from specified files; --cpuset="0-2" or --cpuset="0,1,2": bind the container to the specified CPU; -m: sets the maximum memory used by a container. - net = "bridge" : specify the container's network connection type, support bridge/host/none/container: four types; --link=[]: Add link to another container; --expose=[]: Open a port or group of ports; --volume, -v: Binds a volumeCopy the code

4, Docker get portainer image, install Portainer container

Portainer is a visual page of Docker, which can be opened for visual operation after installation.

1. Search for portainer images

docker search portainer
Copy the code

2. Pull the Portainer image

docker pull portainer/portainer:latest
Copy the code

3. Install and start a Portainer container

docker run -d  --name portainer  -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock --restart always --privileged=true portainer/portainer
Copy the code

4. Enter in the browserhttp://ip:9000 can access the Portainer, enter the visualization page, and operate the corresponding Images and Containers, as shown in the figure below:

5. Docker obtains Jenkins image and installs Jenkins container

1. Search Jenkins mirror

docker search jenkins
Copy the code

2. Pull Jenkins mirror image

docker pull jenkins/jenkins:lts
Copy the code

3. Create a Jenkins directory

mkdir /home/jenkins_home
Copy the code

4. Start a Jenkins container and bind the JDK path to the Maven path

docker run --name jenkins\ -u root\ -d\ -p 8061:8080\ -p 50000:50000\ -v /usr/bin/docker:/usr/bin/docker:Z \ -v /var/run/docker.sock:/var/run/docker.sock:Z \ -v /etc/sysconfig/docker:/etc/sysconfig/docker:Z \ -v / opt/software/jdk1.8.0 _201: / opt/software/jdk1.8.0 _201: Z \ - v / opt/software/apache maven - 3.6.3: / opt/software/apache maven - 3.6.3: Z \ - v /opt/software/maven-repo:/opt/software/maven-repo:Z \ -v /home/jenkins_home:/var/jenkins_home:Z \ --restart=always \ --privileged=true \ jenkins/jenkins:ltsCopy the code

5. Check Jenkins service

docker ps | grep jenkins
Copy the code

6. Enter the Jenkins container

docker exec -it jenkins_01 bash
Copy the code

7, as shown in theBlog.csdn.net/DZP_dream/a…

Docker obtains the SVN image and installs the SVN container

1. Search for the SVN image

docker search svn
Copy the code

2. Pull the SVN image

docker pull garethflowers/svn-server:latest 
Copy the code

3. Create a SVN container

docker run --privileged=true  --restart always --name svn -d -v /root/dockers/svn:/var/opt/svn -p 3690:3690 garethflowers/svn-server 
Copy the code

4. Access the SVN container

docker exec -it svn /bin/sh
Copy the code

5. Create a repository

[root@local /]# docker exec -it svn /bin/sh
/var/opt/svn # svnadmin create project
Copy the code

6. Location of the SVN

/root/dockers/svn/project
Copy the code

7, as shown in theBlog.csdn.net/DZP_dream/a…

Docker obtain the Tomcat image and install the Tomcat container

1. Search for the Tomcat image

docker search tomcat
Copy the code

2. Pull the Tomcat image

docker pull tomcat:7-jre7
Copy the code

Create a Tomcat container

docker run -di --name jenkins_tomcat -p 9000:8080 -v /usr/local/myhtml:/usr/local/tomcat/webapps --privileged=true tomcat:7-jre7
Copy the code

4. Enter the Tomcat container

docker exec -it jenkins_tomcat /bin/bash
Copy the code

5. Copy tomcat webapps.dist to /usr/local/myhtml and rename it webapps.

cd /usr/local/myhtml
docker cp jenkins_tomcat:/usr/local/tomcat/webapps.dist webapps
Copy the code

Docker install mysql container

1. Search the mysql image

docker search mysql
Copy the code

2, pull mysql image

Docker pull mysql: 5.7Copy the code

3, create mysql container and specify time zone

docker run -d --name mysql57 \
-p 3306:3306 \
-v /home/mysql57/conf:/etc/mysql/mysql.conf.d  \
-v /home/mysql57/logs:/logs \
-v /home/mysql57/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=dzp_dream  \
-e TZ=Asia/Shanghai \
--restart always  \
mysql:5.7 \
--lower_case_table_names=1 \
--default-time_zone='+8:00'
Copy the code

Note: -e TZ=Asia/Shanghai and –default-time_zone=’+8:00′ set the time zone

--lower_case_table_names=1 Set to case insensitiveCopy the code

4. Enter the mysql container

docker exec -it mysql57 /bin/bash
Copy the code

5. Enter mysql

mysql -u root -p

Docker install nginx container

1. Search for nginx images

docker search nginx
Copy the code

2. Pull the Nginx image

docker pull nginx:latest
Copy the code

Create an nginx container

docker run -d --name newnginx \
-p 80:80 \
-v /nginx/html:/usr/share/nginx/html:ro  \
-v  /nginx/conf/conf.d:/etc/nginx/conf.d  \
-v /nginx/logs:/var/log/nginx \
nginx
Copy the code

4. Enter the nginx container

docker exec -it newnginx /bin/bash
Copy the code

5, as shown in theBlog.csdn.net/DZP_dream/a…

Docker get the Redis image and install the Redis container

1. Search for redis images

docker search redis
Copy the code

2. Pull the Redis image

docker pull redis:latest
Copy the code

3. Create redis container and set password

docker run -d --name myredis -p 6379:6379 redis:latest --requirepass "dzp_dream"
Copy the code

4. Enter the Redis container

docker exec -it myredis /bin/bash
Copy the code

5. See Redis high availability for detailsBlog.csdn.net/DZP_dream/a…

Docker obtains the ZooKeeper image and installs the ZooKeeper container

1. Search for the ZooKeeper image

docker search zookeeper
Copy the code

2. Pull the ZooKeeper image

docker pull docker.io/wurstmeister/zookeeper
Copy the code

3. Create a ZooKeeper container

docker run -d --name zookeeper -p 2181:2181 -t wurstmeister/zookeeper
Copy the code

4. Access the ZooKeeper container

docker exec -it zookeeper /bin/bash
Copy the code

Docker install kafka container

1. Search for kafka images

docker search kafka
Copy the code

2. Pull the Kafka mirror

Docker pull docker. IO/wurstmeister kafka: 2.12 2.1.0Copy the code

Create a Kafka container

Docker run -d --name kafka -p 9092:9092 -e KAFKA_BROKER_ID=0 -e KAFKA_ZOOKEEPER_CONNECT= 172.17.0.5:2181-e KAFKA_ADVERTISED_LISTENERS = PLAINTEXT: / / 192.168.189.130-9092 - e KAFKA_LISTENERS = PLAINTEXT: / / 0.0.0.0:9092 - t Wurstmeister/kafka: 2.12-2.1.0Copy the code

4. Enter the Kafka container

docker exec -it kafka /bin/bash
Copy the code

Postgresql + PostGIS: postgresQL + PostGIS

1. Search for postgresQL + PostGIS images

docker search postgresql
Copy the code

2. Pull the PostgresQL + PostGIS image

Docker pull kartoza/postgis: 11.0 to 2.5Copy the code

3. Create a PostgresQL + PostGIS container

docker run -t --name postgresql --restart always -e POSTGRES_USER='postgres' -e POSTGRES_PASSWORD=dzp_dream -e ALLOW_IP_RANGE=0.0.0.0/0 -p 5432:5432 -d Kartoza /postgis:11.0-2.5Copy the code

4. Enter the PostgresQL + PostGIS container

docker exec -it postgresql /bin/bash
Copy the code

Docker obtains the MinIO image and installs the MinIO container

1. Search for the MinIO image

docker search minio
Copy the code

2. Pull the MinIO image

docker pull minio/minio
Copy the code

3. Create MinIO containers

docker run -d -p 9001:9000 --name minio \
-e "MINIO_ACCESS_KEY=minio" \
-e "MINIO_SECRET_KEY=dzp_dream" \
-v /opt/app/cloud/minio/data:/data \
-v /opt/app/cloud/minio/config:/root/.minio \
minio/minio server /data
Copy the code

4. Enter the MinIO container

docker exec -it minio /bin/bash
Copy the code

5. Install the MinIO clusterBlog.csdn.net/DZP_dream/a…

15. Docker obtains gitLab image and installs gitLab container

1. Search for gitLab images

docker search gitlab
Copy the code

2. Pull the GitLab image

docker pull gitlab/gitlab-ce
Copy the code

3, Create gitlab container (if SElinux is enabled, add “:Z” after the command to map volume)

Docker run -d -p 8443:443 \ -p 80:80 \ -p 222:22 \ --name gitlab \ --restart always \ --hostname 192.168.189.130 \ -v /home/gitlab/config:/etc/gitlab:Z \ -v /home/gitlab/logs:/var/log/gitlab:Z \ -v /home/gitlab/data:/var/opt/gitlab:Z \ gitlab/gitlab-ceCopy the code

4. Enter the GITLab container

docker exec -it gitlab /bin/bash
Copy the code

5. Visit GitLab

Direct access via browser IP (port 80 by default)

Xvi. Docker obtain the Nacos image and install the Nacos container

1. Search for Nacos images

docker search nacos/nacos-server
Copy the code

2. Pull the Nacos image

docker pull nacos/nacos-server
Copy the code

Create a Nacos container

docker run --env MODE=standalone --name nacos -d -p 8848:8848 nacos/nacos-server
Copy the code

4. Enter the Nacos container

docker exec -it nacos /bin/bash
Copy the code

5. Access: Use IP address :8848/nacos. The default login password is nacos/nacos

Docker install elasticSearch container

1. Search for elasticSearch images

docker search elasticsearch
Copy the code

2. Pull the image of ElasticSearch

docker pull elasticsearch
Copy the code

Create elasticSearch

docker run -d --name ES01 \
-e "ES_JAVA_OPTS=-Xms256m -Xmx256m" \
-p 9200:9200 -p 9300:9300 \
docker.io/elasticsearch
Copy the code

4. Access the elasticSearch container

docker exec -it elasticsearch /bin/bash
Copy the code

5. Access: Passhttp://ip:9200/Access, the following installation is successful

6, as shown in theBlog.csdn.net/DZP_dream/a…

Docker obtain RabbitMQ image and install RabbitMQ container

1. Search for RabbitMQ images

docker search rabbitmq:management
Copy the code

2. Pull the RabbitMQ image

docker pull rabbitmq:management
Copy the code

3. Create RabbitMQ containers

docker run -d --hostname my-rabbit --name rabbit -p 15672:15672 -p 5672:5672 docker.io/rabbitmq:management
Copy the code

4. Enter the RabbitMQ container

docker exec -it rabbit /bin/bash
Copy the code

5. Access: Passhttp://ip:15672/Access, the following installation is successful

6. See:Blog.csdn.net/DZP_dream/a…

Docker install the registry container

1. Search for the Registry image

docker search registry 
Copy the code

2. Pull the Registry image

docker pull registry 
Copy the code

Create a Registry container

docker run --name=registry -p 5000:5000 -di registry
Copy the code

Enter the Registry container

docker exec -it registry /bin/bash
Copy the code

5. Modify the configuration file

 vim /etc/docker/daemon.json
Copy the code

Add the following:

{" insecure - registries: "[]" 192.168.1.175:5000 "}Copy the code

6. Make it take effect and restart docker

sudo systemctl daemon-reload
sudo systemctl restart docker
Copy the code

7. Access: Passhttp://ip:5000/v2/_catalogAccess, the following installation is successful

Docker install the Memcached image

1. Search the Memcached image

docker search memcached 
Copy the code

2. Pull the Memcached image

docker pull memcached
Copy the code

Create the Memcached container

docker run -d --name mymemcache -p 11211:11211  memcached
Copy the code

4. Operations related to Memcached

Telnet 127.0.0.1 11211 set test 0 900 9 memcached STORED get test VALUE test 0 9 memcached END quitCopy the code

Docker obtain the MongoDB image and install the MongoDB container

1. Search for MongoDB images

docker search mongo
Copy the code

2. Pull the MongoDB image

docker pull mongo:latest
Copy the code

3. Create the MongoDB container

docker run -itd --name mymongo -p 27017:27017 mongo --auth
Copy the code

4. Go to the MongoDB container

Docker exec -it mymongo mongo admin # create a user named admin with password 123456. > db.createUser({ user:'admin',pwd:'123456',roles:[ { role:'userAdminAnyDatabase', db: 'admin'}]}); # try to connect using the user information created above. > db.auth('admin', '123456')Copy the code

Docker obtains the Nexus3 image and installs the Nexus3 container

1. Search for the Nexus3 image

docker search nexus
Copy the code

2. Pull the Nexus3 mirror

docker pull docker.io/sonatype/nexus3
Copy the code

Create a Nexus3 container

docker run -itd -p 8081:8081 --privileged=true --name nexus3 \
-v /data/nexus-data:/var/nexus-data --restart=always docker.io/sonatype/nexus3
Copy the code

4. Enter the Nexus3 container

docker exec -it nexus3 /bin/bash 
Copy the code

5, as shown in theBlog.csdn.net/DZP_dream/a…

23. Check all containers

24. Installation of other containers

Installation of other containers is similar to the above steps.

Reference address: blog.csdn.net/DZP_dream/a…