1. Prepare the Docker environment for cloud server

Specific can operate according to the following steps

1. Docker installation

1. Install the Docker dependent libraries

yum install -y yum-utils device-mapper-persistent-data lvm2
1
Copy the code

2. Add the software source information of Docker CE

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

Note: yum -y install Docker will install the latest version of Docker CE by default

yum makecache fast
yum -y install docker-ce
Copy the code

4. Start the Docker service

systemctl start docker
Copy the code

3. Aliyun acceleration

Ali cloud service, container image service

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://4g4r3y39.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
Copy the code

4, hello world

docker run hello-world
Copy the code

Pull the Redis image

Docker pull redis // Pull redis images from the repository // view the downloaded redis imagesCopy the code

Configure the redis configuration file and start the Redis service

  1. Conf file on the cloud server, upload the file to **/data/redis/redis.conf** on the cloud server, and create a directory **/data/redis/data**
  2. Run the following command to start redis in the Docker container
docker run -p 6379:6379 --name redis -v /data/redis/redis.conf:/etc/redis/redis.conf -v /data/redis/data: /data -d redis redis-server /etc/redis/redis.conf --appendonly yes
Copy the code
  1. Run the following command to view the Redis process in the container
docker ps 
Copy the code

Connect the redis in the container

Run the following command to connect the redis in the container

docker exec -it 74322a034baf redis-cli  //74322A034baf indicates the id of the containerCopy the code