Yourls password connection error: can't connect to MySQL

I am trying to get the following working: yourls - Official Image | Docker Hub.

For testing purposes simply used the compose file as stated.

version: '3.1'


    image: yourls
    restart: always
      - 8080:80
      YOURLS_DB_PASS: example
      YOURLS_USER: example_username
      YOURLS_PASS: example_password

    image: mysql
    restart: always
      MYSQL_ROOT_PASSWORD: example
      MYSQL_DATABASE: yourls

The two containers come up and appear to be running fine but when I browse to, I get

I am assuming that the 2nd part of the docker compose file creates the MySQL database, setting the root password to “example” but I might be wrong.

Yes, MYSQL_ROOT_PASSWORD sets the password but only when the contain starts the first time. If you change it later, you have to do it manually. It also takes time and the yourls service could strt before the database is initialzed, but I assume you tried multiple times after waiting a couple of minutes.

Yes I did but I did not wait too long the first time so maybe that broke things. Going to remove everything and try again.