Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error response from daemon: attaching to network failed, make sure your network options are correct and check manager logs: context deadline exceeded

I am trying to set up docker swarm with an overlay network. I have some hosts on aws while others are laptops running Ubuntu(same as on aws). Every node has a static public IP. I have created an overlay network as: docker network create --driver=overlay --attachable test-net

I have created a swarm network on one of the aws hosts. Every other node is able to join that swarm network.

However when I run docker run -it --name alpine2 --network test-net alpine on any node not on aws, I get the error: docker: Error response from daemon: attaching to network failed, make sure your network options are correct and check manager logs: context deadline exceeded.

But if I run the same on any aws host, then everything is working fine. Is there anything more I need to do in terms of networking/ports If there are some nodes on aws while others are not?

I have opened the ports required for swarm networking on all machines.

EDIT: All the nodes are marked as "active" when listing in the manager node.

UPDATE Solved this issue by opening the respective ports. It now works if all the nodes are Linux based. But when I try to make a swarm with the manager as Linux(ubuntu) os, mac os machines are not able to join the swarm.

like image 285
Swapnil Pandey Avatar asked Aug 07 '19 06:08

Swapnil Pandey


2 Answers

check if the node in drain state:

docker node inspect --format {{.Spec.Availability}} node

if yes then update the state:

docker node update --availability active node

here is the explanation:

Resolution

When a node is in drain state, it is expected behavior that you should not be able to allocate swarm mode resources such as multi-host overlay network IP addresses to the node.However, swarm mode does not currently provide a messaging mechanism between the swarm leader where IP address management occurs back to the worker node that requested the IP address. So docker run fails with context deadline exceeded. Internal engineering issue escalation/292 has been opened to provide a better error message in a future release of the Docker daemon.

source

like image 147
LinPy Avatar answered Sep 25 '22 02:09

LinPy


Check if the below ports are opened on both machines.

  • TCP port 2377
  • TCP and UDP port 7946
  • UDP port 4789

You may use ufw to allow the ports:

ufw allow 2377/tcp
like image 25
user1804108 Avatar answered Sep 22 '22 02:09

user1804108