Issue linking containers in Docker using Docker-compose

I’m using Docker to get my micro services architecture ready.
I’m facing some problem trying to link one container with another using docker-compose.

Basically I have a container for a postgressql image, and the a java micro service developed with spring boot that should connect to the database container.

  • Docker TLS Error on Ubuntu
  • Connecting Docker container to corporate LDAP server through SSL
  • Spring Cloud Eureka Client
  • chmod not work with virtualbox share folder
  • GPU becomes unavailable when computer goes to sleep
  • Gitlab CI and Docker throws error when migrating
  • So I’m setting a link in docker-compose.yml and referencing the db container ip as ‘db’ using :

    - ""

    However I’m getting the following error starting the microservice with docker:

    Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder ‘’ in value “jdbc:postgresql://${}:5432/docker”

    So basically this placeholder cannot be resolved, but normally docker-composed should take care of setting this system variable to point to the db container IP address right?

    What I’m doing wrong?

    Below the files involved:


        version: "2"
          build: ./microservices
          container_name: microservices
            - db
            - consul
            - ""
          image: consul
          container_name: consul
                    - "8500:8500"
        image: postgres
        container_name: local-postgres9.6
              - "5432:5432"
          POSTGRES_PASSWORD: docker
          POSTGRES_USER: docker

    application.yml of the microservice:

      port: 8081
        url: jdbc:postgresql://${}:5432/docker
        driver: org.postgresql.Driver
        username: docker
        password: docker

  • docker daemon not connecting
  • Unable to mount specific paths as volumes
  • docker-compose get ID of a docker
  • Where i can find windows 64 bit box for vagrant
  • Can't change PHP variables in Joomla docker official container
  • Simple Flask application with debug set to True is not reloading in Docker?
  • One Solution collect form web for “Issue linking containers in Docker using Docker-compose”

    Try ${}, according to the documentation:

    Containers for the linked service will be reachable at a hostname
    identical to the alias, or the service name if no alias was specified.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.