'attaching to network failed, make sure your network options are correct and check manager logs: context deadline exceeded
I am trying to use overlay network with docker-compose up
(in swarm mode) because I need some other swarm to connect to that network as well.
I am getting this error:
ERROR: for elk_elasticsearch_1 Cannot start service elasticsearch: attaching to network failed, make sure your network options are correct and check manager logs: context deadline exceeded
ERROR: for elasticsearch Cannot start service elasticsearch: attaching to network failed, make sure your network options are correct and check manager logs: context deadline exceeded
ERROR: Encountered errors while bringing up the project.
Here's my docker-compose:
networks:
elk-network:
attachable: true
driver: overlay
name: elk-network
services:
elasticsearch:
build:
args:
ELK_VERSION: 7.1.1
context: /home/user/elk/elasticsearch
environment:
ELASTIC_PASSWORD: password
ES_JAVA_OPTS: -Xmx256m -Xms256m
networks:
elk-network:
ports:
- published: 9200
target: 9200
- published: 9300
target: 9300
restart: always
volumes:
- /home/user/elk/elasticsearch/config/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml:ro
- /home/user/elk/data:/usr/share/elasticsearch/data:rw
kibana:
build:
args:
ELK_VERSION: 7.1.1
context: /home/user/elk/kibana
depends_on:
- elasticsearch
networks:
elk-network:
ports:
- published: 5601
target: 5601
restart: always
volumes:
- /home/user/elk/kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml:ro
version: '3.5'
The node Spec.Availability says active. I'm not finding any other information about what to do by googling the error.
The network called elk-network
actually shows up in docker network ls
2l911valz0a8 elk-network overlay swarm
Edit: Another thing I've discovered from trying to debug is it works perfectly on my mac and on another server, but it doesn't work on the one server I need it to. Any way I can get more info about what's going on?
Solution 1:[1]
Perhaps you also need to play with the subnet parameters, gateway, IP ranges, etc.
Example:
docker network create -d overlay \
--subnet=192.168.0.0/16 \
--subnet=192.170.0.0/16 \
--gateway=192.168.0.100 \
--gateway=192.170.0.100 \
--ip-range=192.168.1.0/24 \
--aux-address="my-router=192.168.1.5" --aux-address="my-switch=192.168.1.6" \
--aux-address="my-printer=192.170.1.5" --aux-address="my-nas=192.170.1.6" \
elk-network
Solution 2:[2]
I solved my issue by uninstalling docker from snap and reinstalling using apt
using these commands;
sudo snap remove docker
sudo dpkg --configure -a
sudo apt update -y
sudo apt install docker.io
sudo reboot
After that, I was able to successfully create my network.
I do the dpkg
and update
command to make sure my system is clean for re-install.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | J. Scott Elblein |
Solution 2 | Maarten |