Discover how Dropbox streamlined dev environments & cut costs by switching 1000 developers to Coder

Read the success story

Coder for Docker
External database setup

External database setup

External database setup

If you'd like to use an external database with your Coder for Docker deployment, you must:

  1. Disable the embedded database by setting the DB_EMBEDDED environment variable (see the next code snippet for an example)

  2. Provide the connection information to the external PostgreSQL database:

    docker run --rm -it -p 7080:7080 \
       -v /var/run/docker.sock:/var/run/docker.sock \
       -v ~/.coder:/var/run/coder \
       # Disable using the embedded DB
       -e DB_EMBEDDED="" \
       # Change these values to match those for your database
       -e DB_HOST= \
       -e DB_PORT=5432 \
       -e DB_USER=postgres \
       -e DB_PASSWORD="" \
       -e DB_NAME=postgres \
       -e DB_SSL_MODE=disable \

Coder supports client TLS certificates using DB_SSL_MODE=verify-full. Ensure that you mount the certs into the container (and add the flag -v <local_certs>:/certs). Then, specify the certificate path using environment variables:

Flag/environment variableDescription
-e DB_CERT=/certs/client.crtThe path to the client cert signed by the CA
-e DB_KEY=/certs/client.keyThe path to the client secret
-e DB_ROOT_CERT=/certs/myCA.crtThe path to the trusted CA cert
See an opportunity to improve our docs? Make an edit.