下面四项都设置为yes
[root@HK ~]# grep -Ei 'AllowAgentForwarding|AllowTcpForwarding|GatewayPorts|X11Forwarding' /etc/ssh/sshd_config AllowAgentForwarding yes AllowTcpForwarding yes GatewayPorts yes X11Forwarding yes [root@HK ~]#
# vim /usr/lib/systemd/system/docker.service 在 ExecStart=/usr/bin/dockerd-current 后 增加 -H tcp://127.0.0.1:2375 -H unix://var/run/docker.sock # 重启docker,重新读取配置文件,重新启动docker服务 systemctl daemon-reload systemctl restart docker netstat -tunlp | grep 2375
1.获取转发要绑定的内网ip: [root@HK ~]# docker inspect --format='{{.NetworkSettings.Gateway}}' portainer 172.17.0.1 # 绑定ip为本地内网端口 autossh -M 23353 -NL 172.17.0.1:23753:127.0.0.1:2375 us >/dev/null 2>&1 &
1. web访问portainer Endpoints http://公网ip:9000/#/endpoints 2. Add endpoint 3. 选择[docker](Directly connect to the Docker API) 4.输入name(us) 和Endpoint URL(172.17.0.1:23753)