MySQL issues installing via Docker

I have been trying like hell to get IN installed via docker using docker compose. I’ve followed the docs, followed two different videos and tried things I’ve found searching the issues.

I have tried installing this in a DigitalOcean VPS as well as my owner homelab server. No go with either.

My problem appears to be connecting to MySQL. Connection fails and the container restarts. Over and over and over. This is the output of the MySQL container logs:

2024-01-31 18:04:35+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.3.0-1.el8 started.
2024-01-31 18:04:37+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2024-01-31 18:04:37+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.3.0-1.el8 started.
'/var/lib/mysql/mysql.sock' -> '/var/run/mysqld/mysqld.sock'

That just repeats over and over every few seconds. This is error in the app log:

In Connection.php line 822:

  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for db failed:
   Try again (Connection: mysql, SQL: select table_name as `name`, (data_leng
  th + index_length) as `size`, table_comment as `comment`, engine as `engine
  `, table_collation as `collation` from information_schema.tables where tabl
  e_schema = 'ninja' and table_type in ('BASE TABLE', 'SYSTEM VERSIONED') ord
  er by table_name)


In Connector.php line 65:

  SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo for db failed:
   Try again


In Connector.php line 65:

  PDO::__construct(): php_network_getaddresses: getaddrinfo for db failed: Tr
  y again

Here is my env file:

# IN application vars
APP_URL=http://myip:8555
APP_KEY=somethingsomethingsecret
APP_DEBUG=true
REQUIRE_HTTPS=false
PHANTOMJS_PDF_GENERATION=false
PDF_GENERATOR=snappdf
TRUSTED_PROXIES='*'


QUEUE_CONNECTION=database

# DB connection
DB_HOST=db
DB_PORT=3306
DB_DATABASE=ninja
DB_USERNAME=ninja
DB_PASSWORD=ninja

# Create initial user
# Default to these values if empty
# IN_USER_EMAIL=admin@example.com
# IN_PASSWORD=changeme!
IN_USER_EMAIL=me@example.com
IN_PASSWORD=thepassword

# Mail options
MAIL_MAILER=log
MAIL_HOST=my.smtp.relay.example.com
MAIL_PORT=587
MAIL_USERNAME=email@example.com
MAIL_PASSWORD=secretstuff
MAIL_ENCRYPTION=tls
MAIL_FROM_ADDRESS='user@example.com'
MAIL_FROM_NAME='Self Hosted User'

# MySQL
MYSQL_ROOT_PASSWORD=ninjaAdm1nPassword
MYSQL_USER=ninja
MYSQL_PASSWORD=ninja
MYSQL_DATABASE=ninja

# V4 env vars
# DB_STRICT=false
# APP_CIPHER=AES-256-CBC

I left this as generic as possible after trying multiple times with personalized settings but still no go. Here’s my docker compose:

version: '3.7'

services:
  server:
    image: nginx
    restart: always
    env_file: env
    volumes:
      # Vhost configuration
      #- ./config/caddy/Caddyfile:/etc/caddy/Caddyfiledocker-com
      - ./config/nginx/in-vhost.conf:/etc/nginx/conf.d/in-vhost.conf:ro
      - ./docker/app/public:/var/www/app/public:ro
    depends_on:
      - app
    # Run webserver nginx on port 80
    # Feel free to modify depending what port is already occupied
    ports:
      - "8555:80"
      #- "443:443"
    networks:
      - invoiceninja

  app:
    image: invoiceninja/invoiceninja:5
    env_file: env
    restart: always
    volumes:
      - ./config/hosts:/etc/hosts:ro
      - ./docker/app/public:/var/www/app/public:rw,delegated
      - ./docker/app/storage:/var/www/app/storage:rw,delegated
      - ./config/php/php.ini:/usr/local/etc/php/php.ini
      - ./config/php/php-cli.ini:/usr/local/etc/php/php-cli.ini

    depends_on:
      - db
    networks:
      - invoiceninja

  db:
    image: mysql:8
    ports:
      - "3305:3306"
    restart: always
    env_file: env
    volumes:
      - ./docker/mysql/data:/var/lib/mysql:rw,delegated

    networks:
      - invoiceninja

networks:
  invoiceninja:

I can provide further information if needed but please be wordy in what you are requesting as I am pretty new to docker. Thank you.

Hi,

Are you using the official docker file?

Hi, @fallupdownthere,

is it possible that you try to install docker with the automatic SQL-backups? There’s a problem with that, so this does not work. The script which creates a customized docker-container hangs at a point, where the basing debian shall get an update. But there’s a problem with an gpg-key, so the update won’t finish.

My hint, if this is the scenario you are facing, just take one of the standard-SQL-repos (MySQL 8 or MariaDB) and do the backups by a cron- or systemd-job by the docker-server itself.

Greetz

Yes, I used the official Docker files.

No, I am not using the SQL backups.

When you first set it up, did you access /setup ? If not, then no database tables would have been created.
If it’s a database connection issue you should check the docker logs for the db container and perhaps restart the db container.
Check the DB_HOST setting if changing to the IP address will fix.
Also, you can install mariadb server on the host computer, create an account with access and enter that as the database server in the env file if you don’t want to use the docker db.

Yeah, I tried accessing setup and nothing would work. However, I finally did get it working (somewhat, still dealing with a few issues).

The issue was the DB connection so I decided to setup mariadb in a separate container outside of invoiceninja. After spinning up that container I confirmed it was working and I could access it and then installed the invoiceninja containers sans the DB. All seemed to go well and I was finally able to get to the login screen but my password would not work. MAKES ABSLUTELY ZERO SENSE. I tried changing the password in the env, taking down the containers, deleting them, repull, etc and it did not work.

Tried the “reset password” link but no emails were going out. Opened the laravel log and the entire reset password email was in there including the link to reset the password (yet another issue). Copied that link and pasted in my browser and was able to reset my password and finally log in. I still don’t have it on SSL nor on a domain name which is the next adventure which I am sure will go perfectly smoothly.