Skip to content
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

Open
asteinarson opened this issue Aug 5, 2020 · 1 comment
Open
Labels
docker Related to the Docker setup

Comments

@asteinarson
Copy link

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?

@asteinarson
Copy link
Author

...I should mention that I do get the unmodified docker-compose.yaml to work, where Directus and MySQL are created in the same script and connected via links.

@benhaynes benhaynes transferred this issue from another repository Nov 18, 2020
@benhaynes benhaynes added the docker Related to the Docker setup label Nov 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
docker Related to the Docker setup
Projects
None yet
Development

No branches or pull requests

2 participants