portainer / portainer

Making Docker and Kubernetes management easy.
https://www.portainer.io
zlib License
31.08k stars 2.48k forks source link

Portainer docker service not working when deploying as swarm #6344

Open ha1o0 opened 2 years ago

ha1o0 commented 2 years ago

Bug description exec curl -L https://downloads.portainer.io/portainer-agent-stack.yml \ -o portainer-agent-stack.yml and docker stack deploy -c portainer-agent-stack.yml portainer

the docker service portainer_portainer and portainer_agent not working

Expected behavior portainer docker service work

Portainer Logs portainer_portainer.1.yfrl6p20s82r@OptiPlex-3020 | level=info msg="2021/12/31 02:51:04 failed initializing environment: Get \"https://tasks.agent:9001/_ping\": dial tcp: lookup tasks.agent on 127.0.0.11:53: read udp 127.0.0.1:56498->127.0.0.11:53: read: connection refused"

Steps to reproduce the issue: There is only one manage node in my docker swarm.

Technical details:

Additional context ufw and iptables are both closed. I can deploy the portainer as singlone service by docker run -d -p 8000:8000 -p 9443:9443 --name portainer \ --restart=always \ -v /var/run/docker.sock:/var/run/docker.sock \ -v portainer_data:/data \ portainer/portainer-ce:2.11.0

but it not work when i use docker swarm mode.

samdulam commented 2 years ago

@weifengsmile Looks like tasks.agent is not being resolved. Most likely to be an issue with Swarm Overlay networking. Do you have the necessary FW ports open between the servers? Is docker DNS working? FW Port details: https://www.digitalocean.com/community/tutorials/how-to-configure-the-linux-firewall-for-docker-swarm-on-ubuntu-16-04 Check Swarm Networking: https://gist.github.com/alexellis/8e15f2ea1af7281268ec7274686985ba

ha1o0 commented 2 years ago

@weifengsmile Looks like tasks.agent is not being resolved. Most likely to be an issue with Swarm Overlay networking. Do you have the necessary FW ports open between the servers? Is docker DNS working? FW Port details: https://www.digitalocean.com/community/tutorials/how-to-configure-the-linux-firewall-for-docker-swarm-on-ubuntu-16-04 Check Swarm Networking: https://gist.github.com/alexellis/8e15f2ea1af7281268ec7274686985ba

Thanks for your reply.

1.The Firewall (ufw and iptables) has been closed.

  1. This is the docker networking check result: 截屏2021-12-31 下午12 25 14 截屏2021-12-31 下午12 25 35

So how can i do to solve the tasks.agent problem?

samdulam commented 2 years ago

Have you done any of these tests listed here.. https://gist.github.com/alexellis/8e15f2ea1af7281268ec7274686985ba#file-redis-md How many nodes do you have in your cluster? Where are the nodes hosted? Which Hypervisor or Public cloud?

ha1o0 commented 2 years ago

There are two nodes in my cluster now, and linux node is swarm manager, the other worker node is run on a mac machine. I have done some swarm test as the link. Here is the test result, i use docker swarm start two zookeeper and redis service on another worker node based on the network testnet, but only the portainer service does not work. Do you have some ideas? @samdulam

截屏2021-12-31 下午2 22 38

截屏2021-12-31 下午2 11 58

and the portainer yml file is: 截屏2021-12-31 下午2 07 22

samdulam commented 2 years ago

@weifengsmile Are you able to ping anything from your redis or zookeeper containers? Are they in the same network? From one of those container can you try ping / dig to tasks.<servicename>