docker Getting pro-test

Environmental linux centos7:

1, uninstall the previous version of the docker engine
sudo yum the Remove docker-ce
sudo RM -rf / var / lib / docker

2, Docker package already included in the default CentOS-Extras software source inside. So you want to install docker, yum only need to run the following command:

# yum install docker

3、

After installation is complete, use the following command to start the docker services, and set it to boot:

# systemctl start docker.service
# systemctl enable docker.service

4, mirror source address modification

修改 /etc/docker/daemon.json 内容:
{
  "registry-mirrors": ["https://xffvqg8p.mirror.aliyuncs.com"]
}
sudo systemctl daemon-reload

sudo systemctl restart docker

5, download the image (it can be understood as a Java class)

docker pull rabbitmq

6, create and launch container (it can be understood as an example of a Java class)

docker run --name rabbitmq -d -p 5675:5672 docker.io/rabbitmq

And allows the container to create a name for abbitmq, external port 5675, mirroring is docker.io/rabbitmq

7, docker exec -it rabbitmq1 / bin / bash into the container with the specified name

8, docker ps -a queries all containers

9, docker rm -f fe8cc8ca18ed delete container

10, why should the port mapping? When the container starts, if you do not configure port mapping host machines and virtual machines, external program is unable to access the virtual machine, because there is no port.

11, docker start redis:

docker pull redis

sudo docker run -t -i -p 192.168.1.150:6379:6379 redis:latest /bin/bash

Server: master node docker run -d -p 192.168.1.150:6379:6379 --name redis-master -v / home / redis /: / data docker.io/redis redis-server

slave节点  docker run -itd -p 192.168.1.150:6380:6380 --name redis-slave --link redis-master:master docker.io/redis /bin/bash

 docker run -it --name redis-slave -d -p 192.168.1.150:6301:6379   docker.io/redis  redis-server

客户端:docker run -it --link redis-master --rm docker.io/redis redis-cli -h redis-master -p 6379

docker run -it --link redis-slave --rm docker.io/redis redis-cli -h redis-slave -p 6379

12、

docker container mounted vim

apt-get update

apt-get install vim

13、

Replicated from the host to the containersudo docker cp host_path containerID:container_path

sudo docker cp /home/redis.conf 42446750d633:/data

Copy from the container to the hostsudo docker cp containerID:container_path host_path

14、

Into the container: docker exec -it redis-slave bash

https://blog.csdn.net/simatongming/article/details/78598063

15, docker container being given network restart

docker start d23ae97077b7
Error response from daemon: Cannot restart container d23ae97077b7: driver failed programming external connectivity on endpoint zookeeper (eb77732e83cdbc7d04d262f0f5f524bad965bd35c5d770a635b35f7276c9c02f):  (iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 2181 -j DNAT --to-destination 172.17.0.2:2181 ! -i docker0: iptables: No chain/target/match by that name.

Solution: systemctl restart docker (docker network management problems just fine the next reboot.);

                   docker start d23ae97077b7;

 

 

 

 

 

Guess you like

Origin blog.csdn.net/liuqianduxin/article/details/81735551