Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker cannot link to a non running container - fixed with a reboot

Tags:

docker

I have an ELK stack running on docker on Ubuntu. Occasionally the elasticsearch container will terminate due to a bad query or bad message which is expected behaviour in our development environment.

The issue we have is that after the ES container terminates, it is not possible to restart the Logstash container due to the following error:

Cannot link to a non running container: /elasticsearch AS /logstash/elasticsearch

Full list of commands are:

$ sudo docker stop logstash
$ sudo docker start elasticsearch
$ sudo docker start logstash
 Cannot link to a non running container: /elasticsearch AS /logstash/elasticsearch

I have verified that the ES container does indeed come back up and I can connect to ES via curl but the logstash container will not start.

The logstash container is configured with the following link:

/elasticsearch:/logstash/elasticsearch

Docker version info:

$ docker version
Client:
 Version:      1.11.0
 API version:  1.23

$docker --version    
Docker version 1.11.0, build 4dc5990

Rebooting the entire VM resolves the issues and allows me to correctly restart all the containers and everything is good, until ES terminates again.

Whilst not the end of the world, I'd really rather avoid having to reboot to resolve this issue.

Any ideas?

like image 991
Sam Shiles Avatar asked May 24 '16 12:05

Sam Shiles


People also ask

Can not link to a non running container?

This usually happens when a dependency container has a different ID than the one given ( b2f21b869ccc in the above example). To resolve this issue, force recreate the service, dependency and fix the link to the correct docker ID.

Do Docker containers start on reboot?

Docker provides restart policies to control whether your containers start automatically when they exit, or when Docker restarts. Restart policies ensure that linked containers are started in the correct order. Docker recommends that you use restart policies, and avoid using process managers to start containers.

How do I force a docker container to keep running?

Dockerfile Command to Keep the Container Running Method 1: You can use the -t (pseudo-tty) docker parameter to keep the container running.


1 Answers

It also happens me sometimes, last time was today. You can avoid the reboot by running just

sudo service docker restart

(or similar command depending on your OS)

like image 187
Ville Laitila Avatar answered Oct 20 '22 04:10

Ville Laitila