~/snippets/docker-cannot-link-to-a-non-running-container
Published on

Cannot link to a non running container

126 words1 min read

When starting/restarting a docker container, you may get an error similar to the below:

ERROR: for <service>  Cannot link to a non running container: /b2f21b869ccc_<dependency>_1 AS /<service>_1/<dependency>_1

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.

docker-compose up -d --force-recreate {service}

To force recreate all containers, omit the service:

docker-compose up -d --force-recreate