Generation 1 has been deprecated and is not recommended for new applications.
Convox allows you to link containers by declaring associations in the
docker-compose.yml manifest. Links are created by injecting environment variables that point at the linked container.
This avoids the need for your application to interface with configuration or service discovery mechanisms to find the other services it needs to talk to.
To link containers add a
links section to the relevant container in your
web: build: . ports: - 80:80 links: - database database: image: convox/postgres ports: - 5432
links section in this way will cause the following environment variables to be set for the
Here is an example of what those actually look like with the
DATABASE_HOST=172.17.0.1 DATABASE_PASSWORD=password DATABASE_PATH=/app DATABASE_PORT=5432 DATABASE_SCHEME=postgres DATABASE_URL=postgres://postgres:firstname.lastname@example.org:5432/app DATABASE_USERNAME=postgres
DATABASE_HOST=postgres-i-191910196.us-east-1.elb.amazonaws.com DATABASE_PASSWORD=password DATABASE_PATH=/app DATABASE_PORT=5432 DATABASE_SCHEME=postgres DATABASE_URL=postgres://postgres:email@example.com:5432/app DATABASE_USERNAME=postgres
Most images will work out of the box and will use the
tcp scheme by default. If you’d like to override the scheme or supply default authentication credentials, you can set the following
ENV variables in your image’s
See the convox/redis Dockerfile for an example.
You can also override these
LINK_ variables in your application’s
database: image: example/postgres environment: - LINK_SCHEME=postgres - LINK_PASSWORD=password2 - LINK_USERNAME=postgres - LINK_PORT=5432 ports: - 5432
When a service declares a link, the linked container (
database in our example) needs to expose at least one port so convox can create a load balancer and construct the service URL.
When multiple ports are specified, the first one in the list of ports is used to construct the link URL. This can be overridden with the
LINK_PORT environment variable described above.