How do you register a Postgres container host on docker-compose up?

I have an app (Flask/Pony ORM) container that must register the host for a postgres db container on start up. How can I get the host’s (postgres container) location?

On my local set up I have “localhost” but this does not work in the app container.

  • Docker compose-build with rake assets:precompile
  • Docker with php built-in server
  • How to increase the size of the /dev/shm in docker container
  • impossible to delete a container
  • docker linking how can both containers know each others ip
  • Docker user authentication against LDAP over SSL
  • I tried “172.17.0.2” which was what the pg containers IP when I was not using docker-compose.

    But both of these return an error.

    Is there a way to specify a host location for a particular container in the docker-compose file?

  • redis sentinel high availability haproxy
  • Disable logging on interactive containers
  • windows “C:/Users/<username>/” directories not visible during `docker build` command
  • Containerization of OpenStack services with Kubernetes?
  • internal infrastructure with docker
  • How to specify username and password upon docker push?
  • One Solution collect form web for “How do you register a Postgres container host on docker-compose up?”

    You must link your two container in your docker-compose file. Then you will be able to access to your database using the service name of the container.

    Example

    links:
      - postgres:postgres
    

    Link your docker-compose.yml if you need more help.

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