Issue with config resulting in two docker containers not talking to each other

I have deployed yourls - Official Image | Docker Hub using a portainer stack

version: '3.1'

services:

  yourls:
    image: yourls
    restart: unless-stopped
    ports:
      - 8081:80
    environment:
      YOURLS_DB_PASS: PWD1
      YOURLS_SITE: https://myurls.com
      YOURLS_USER: yourls_user
      YOURLS_PASS: PWD2

  mysql:
    image: mysql
    restart: unless-stopped
    environment:
      MYSQL_ROOT_PASSWORD: PWD3
      MYSQL_DATABASE: yourls

It runs but when I browse to YOURLS — Your Own URL Shortener | https://mylinks.com/, I get

Fatal error

Incorrect DB config, or could not connect to DB
PDOException: SQLSTATE[HY000] [1045] Access denied for user ‘root’@‘172.21.0.2’ (using password: YES)

I am connecting to my server at home via a Cloudflare tunnel (as I do with other docker instances) so maybe it has an issue with this.

Hi,

could be that MYSQL_ROOT_PASSWORD and YOURLS_DB_PASS needs to be the same password

Ok, that was embarrassing… but thanks :slight_smile:

Hehe it happends :smiley:

TBH i was also writing a long post regarding what could be the issue, until i saw the 2 variables :wink: