Quickstart with mysql KO

Docker version 19.03.8, build afacb8b
docker-compose version 1.25.0, build 0a186604
CentOS Linux release 8.1.1911 (Core)

Docker compose file:

version: '3'

services:

  hydra-migrate:
	image: oryd/hydra:latest
	environment:
	  - DSN=mysql://root:[email protected](mysqld:3306)/mysql?max_conns=20&max_idle_conns=4
	command:
	  migrate sql -e --yes
	restart: on-failure

  hydra:
	depends_on:
	  - hydra-migrate
	environment:
	  - DSN=mysql://root:[email protected](mysqld:3306)/mysql?max_conns=20&max_idle_conns=4

  mysqld:
	image: mysql:5.7
	ports:
	  - "3306:3306"
	environment:
	  - MYSQL_ROOT_PASSWORD=secret

docker-compose -f docker-compose-lt.yml up
ERROR: The Compose file is invalid because:
Service hydra has neither an image nor a build context specified. At least one must be provided.

Then I add the image to the hydra service:

version: '3'

services:

  hydra-migrate:
	image: oryd/hydra:latest
	environment:
	  - DSN=mysql://root:[email protected](mysqld:3306)/mysql?max_conns=20&max_idle_conns=4
	command:
	  migrate sql -e --yes
	restart: on-failure

  hydra:
	image: oryd/hydra:latest
	depends_on:
	  - hydra-migrate
	environment:
	  - DSN=mysql://root:[email protected](mysqld:3306)/mysql?max_conns=20&max_idle_conns=4

  mysqld:
	image: mysql:5.7
	ports:
	  - "3306:3306"
	environment:
	  - MYSQL_ROOT_PASSWORD=secret

And I get in the logs (mysql is starting OK, I can connect to the DB on port 3306 from the host)

hydra-migrate_1 | time=“2020-03-25T05:40:55Z” level=info msg=“Establishing connection with SQL database backend” dsn=“mysql://:@tcp(mysqld:3306)/mysql?parseTime=true”
hydra-migrate_1 | time=“2020-03-25T05:40:56Z” level=error msg=“Unable to ping SQL database backend” dsn=“mysql://:@tcp(mysqld:3306)/mysql?parseTime=true” error=“dial tcp 172.24.0.2:3306: connect: no route to host”
hydra-migrate_1 | time=“2020-03-25T05:40:56Z” level=error msg=“Unable to connect to database, retrying…” error=“could not ping SQL connection: dial tcp 172.24.0.2:3306: connect: no route to host”
hydra-migrate_1 | time=“2020-03-25T05:40:56Z” level=info msg=“Retrying in 5.000000 seconds…”
hydra_1 | time=“2020-03-25T05:40:58Z” level=info msg=“Establishing connection with SQL database backend” dsn=“mysql://:@tcp(mysqld:3306)/mysql?parseTime=true”
hydra_1 | time=“2020-03-25T05:40:59Z” level=error msg=“Unable to ping SQL database backend” dsn=“mysql://:@tcp(mysqld:3306)/mysql?parseTime=true” error=“dial tcp 172.24.0.2:3306: connect: no route to host”
hydra_1 | time=“2020-03-25T05:40:59Z” level=error msg=“Unable to connect to database, retrying…” error=“could not ping SQL connection: dial tcp 172.24.0.2:3306: connect: no route to host”
hydra_1 | time=“2020-03-25T05:40:59Z” level=info msg=“Retrying in 5.000000 seconds…”

Please help.

Please refer to the documentation for the appropriate configuration of Hydra ( https://www.ory.sh/docs/hydra/configure-deploy ) and also Docker Compose ( https://docs.docker.com/compose/ ). You’re missing essential configuration items, which are documented in the linked pages, like the ORY Hydra system secret and the Docker Compose network.

1 Like

I do agree that I was missing some conf items, I added them.
Nevertheless man would assume a project kickstart would work out of the box :wink:

Thanks for your help

Of course! That’s why almost all configuration settings are optional or have defaults. For some, it’s not reasonable especially if you use stuff like persistent storage where the system secret can not change.

We can also not change the way Docker works, so stuff like Docker Networking are basic requirements when you work with Docker!