Docker Community Forums

Share and learn in the Docker community.

Container linking - Docker not creating environment variables


(Pmandayam) #1

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?


(Alexbaat) #2

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


(Pmandayam) #3

@alexbaat Thanks, solved the problem