Docker Basic Concepts
Before using Docker, let's look at the core concepts of the next few Docker
Docker Daemon
The Docker engine is a daemon that runs in the background, and after we launch it, we can send Docker-related commands through the Docker client.
Docker Images
Docker image, this is similar to our image when installing Windows, but the image of windows, in the past we usually exist on the CD or USB flash drive, where the image we usually publish to the Docker Registry
Docker Containers
Docker container, after acquiring the Docker image, we can run the image, and a Docker container is launched that runs the program in the Mirror. If the Docker image is understood as a class, then the Docker container is an instance
Docker Client
Docker client, after we have installed Docker, we open the terminal to operate with Docker-related commands, which are the commands of the Docker client, and a rest API-based Docker client, rest APIs are typically used in the development of some Docker operations-based systems.
Docker Registry
Docker image Registry, the registry for Docker's official website is http://hub.docker.com. We can also build our own registration center.
These are the core concepts of Docker, let's look at how to use Docker to install Redis, Zookeeper, Mysql, and in the process, learn some common commands for using Docker client
Installation
Centos
Yum Install Docker
Systemctl Start Docker.service
Systemctl Enable Docker.service
Ubuntu 16.04
sudo apt-get update
sudo apt-key adv--keyserver hkp://p80.pool.sks-keyservers.net:80--recv-keys 58118e89f3a912897c070adbf76221572c52609d
sudo apt-add-repository ' deb Https://apt.dockerproject.org/repo ubuntu-xenial main '
sudo apt-get update
Apt-cache Policy Docker-engine
sudo apt-get install Docker-ce
sudo apt-get install-y docker-engine
sudo systemctl status Docker
Official source
sudo apt-get install \
APT-TRANSPORT-HTTPS \
Ca-certificates \
Curl \
Software-properties-commo
Curl-fssl HTTPS://DOWNLOAD.DOCKER.COM/LINUX/UBUNTU/GPG | sudo apt-key add-
sudo add-apt-repository \
"Deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$ (LSB_RELEASE-CS) \
Stable
Basic use
ElasticSearch
Docker Pull docker.elastic.co/elasticsearch/elasticsearch:5.4.0
Docker run-p 9200:9200-e "http.host=0.0.0.0"-E "transport.host=127.0.0.1" docker.elastic.co/elasticsearch/ elasticsearch:5.4.0
Redis
Find Mirrors
Use the following command to search for a redis mirror in the Docker hub
docker search redis
Pull Mirror
docker pull redis:latest
List all Mirrors
docker images
Create and start a container
docker run -p 6379:6379 -v $PWD/data:/data -d redis:latest redis-server --appendonly yes
Executing the above command, we created and started a Redis container using the redis:latest image, where
-P 6,379:6,379: Map the container's 6379 port to the 6379 port of the host
-V $PWD/data:/data: Mount data from the current directory in the host to the/data of the container
Redis-server--appendonly Yes: Execute the redis-server start command in the container and open the Redis persistence configuration
View Container
Docker PS
Connect a Redis Container
Use a Redis image to connect to a Redis container using the REDIS-CLI client
docker run -it redis:latest redis-cli -h 192.168.0.101
Zookeeper
Next we install zookeeper, we use the same method as Redis. Install directly with minimal steps and no more explanations
Find Zookeeper Images
docker search zookeeper
Pull Mirror
docker pull zookeeper
Create and start a container
docker run -p 2181:2181 -v $PWD/data:/data -d zookeeper:latest
Using the ZOOKEEPRT image to create and start the container, we map the container's 2181 to the 2181 of the machine and also mount the data of the current directory to the container's/data
View the current container list
Docker PS
REFER:
https://docs.docker.com/engine/installation/
Http://www.cnblogs.com/keepcodingforever/p/6698862.html
https://luyiisme.github.io/2017/05/06/elasticsearch-docker-on-one-vm/
Https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html
Configure using Docker on Ubuntu 16.04 server