Container linking - Docker not creating environment variables

Hello I am trying to link my containers following this guide:

https://docs.docker.com/userguide/dockerlinks/

I run docker run -d --name mongodb devops-mongodb

Then I run docker run -d -P --name rest-api --link mongodb devops-rest-api

To link my mongodb container to the rest-api container.

Then the documentation told me to do this to view the environment variables:

docker run --rm --name rest-api2 --link db:db devops-rest-api env

However, it does not print out the environment variables like shown in the docs.

I just get the STDOUT from my Spring Boot application.

What am I doing wrong?

You should replace db:db by mongodb since you’ve named the linked container mongodb.

@alexbaat Thanks, solved the problem