How does portainer connect to remote and manage docker

Usually microservice projects will be deployed on multiple servers. To facilitate management, portainer can be used to centrally manage Docker on each server.

1. Install portainer (note portainer changed from version 2.0.0 image name to portainer/portainer-ce)
docker pull portainer/portainer-ce
2. Start the container
docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock --restart=always --name portainer portainer/portainer-ce

3. You need to create a user for the first login

Visit http://protainer address ip:9000

enter main page

4. Create a new connection

5. The port of the remote docker address is 2375 by default

If the remote docker does not open port 2375, it cannot be connected. The following is the method of configuring the docker port.

1. 编辑docker.service
vim /usr/lib/systemd/system/docker.service
找到 ExecStart字段修改如下
#ExecStart=/usr/bin/dockerd-current -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock 
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:2375 -H unix://var/run/docker.sock

2. 重启docker重新读取配置文件,重新启动docker服务
systemctl daemon-reload
systemctl restart docker

3. 开放防火墙端口
firewall-cmd --zone=public --add-port=6379/tcp --permanent

4.刷新防火墙
firewall-cmd --reload

5.再次配置远程docker就可以了
6.如果重启不起来 估计是这个 unix://var/run/docker.sock 文件位置不对 
find / -name docker.sock 查找一下正确位置就好了

6. The connection is successful

Guess you like

Origin blog.csdn.net/SHUKAI618/article/details/117154921