This repository has been archived by the owner on Jan 6, 2023. It is now read-only.
Unable to connect to DB using other than links in docker-compose.yaml #2100
Labels
docker
Related to the Docker setup
The background to this issue is that I wanted to use the Docker compose file to connect to a pre-existing database.
So I essentially only changed the DB host in docker-compose.yaml:
DIRECTUS_DATABASE_HOST: "mysql"
to:
DIRECTUS_DATABASE_HOST: "172.17.0.3"
I.e. using an IP address (in place of the compose link). On trying this out (running
docker-compose run --rm directus install ...
I get:Installing database... Failed to connect to the database Seems like database failed to install.
Even if I know that the IP and the credentials of the MySQL DB are correct (they are all on the default bridged network) (I can see and connect to the DB from other MySQL containers I created via other docker-compose scripts).
For me, using a Directus Docker image and connecting it to an existing DB would be common scenario.
Here is my docker-compose.yaml:
version: "3"
services:
directus:
image: directus/directus:v8-apache
ports:
- "8080:80"
environment:
DIRECTUS_APP_ENV: "production"
DIRECTUS_AUTH_PUBLICKEY: "some random secret"
DIRECTUS_AUTH_SECRETKEY: "another random secret"
DIRECTUS_DATABASE_HOST: "172.17.0.3"
DIRECTUS_DATABASE_PORT: "3306"
DIRECTUS_DATABASE_NAME: "directus"
DIRECTUS_DATABASE_USERNAME: "directus"
DIRECTUS_DATABASE_PASSWORD: "directus"
volumes:
- ./data/config:/var/directus/config
- ./data/uploads:/var/directus/public/uploads
network_mode: "bridge"
Can you please advice?
The text was updated successfully, but these errors were encountered: