mautic/docker-mautic

Basic Docker compose Environment Variable issues

Closed this issue · 11 comments

After done docker-compose up I see these line in the web container:

Check that mariadbd is running and that the socket: '/run/mysqld/mysqld.sock' exists!
mysqladmin: connect to server at '' failed
error: 'Can't connect to server on 'localhost' (99)'
Check that mariadbd is running and that the socket: '/run/mysqld/mysqld.sock' exists!

seems that the environment variables aren't properly set.

Thanks

@devilmind81

could you retry with Mysql instead of MariaDB to rule out it's related to the database (and the supported env vars?

working only if I add manually the environments values to the docker-compose file under mautic_web:

  environment:
  - MAUTIC_DB_HOST=db
  - MAUTIC_DB_PORT=3306
  - MAUTIC_DB_DATABASE=mautic_db
  - MAUTIC_DB_USER=mautic_db_user
  - MAUTIC_DB_PASSWORD=mautic_db_pwd
  - MAUTIC_DB_ROOT_PASSWORD=changeme
  - DOCKER_MAUTIC_RUN_MIGRATIONS=false
  - DOCKER_MAUTIC_LOAD_TEST_DATA=false

@devilmind81

that's really strange.
Can you provide following information?

  • Docker compose version by executing docker compose version
  • if you have jq installed, the outcome of the command docker compose config --no-path-resolution --no-normalize --format=json mautic_web | jq .services.mautic_web.environment
  • if you don't have jq installed, the outcome of the command docker compose config --no-path-resolution --no-normalize --format=json mautic_web

Hi, these are the outputs:

Docker Compose version v2.24.5

$ docker compose config --no-path-resolution --no-normalize --format=json mautic_web | jq .services.mautic_web.environment
{
"DOCKER_MAUTIC_LOAD_TEST_DATA": "false",
"DOCKER_MAUTIC_RUN_MIGRATIONS": "false",
"MAUTIC_DB_DATABASE": "mautic_db",
"MAUTIC_DB_HOST": "db",
"MAUTIC_DB_PASSWORD": "mautic_db_pwd",
"MAUTIC_DB_PORT": "3306",
"MAUTIC_DB_ROOT_PASSWORD": "changeme",
"MAUTIC_DB_USER": "mautic_db_user",
"MAUTIC_MESSENGER_DSN_EMAIL": "doctrine://default",
"MAUTIC_MESSENGER_DSN_HIT": "doctrine://default"
}

@devilmind81

is this without adding the extra lines?
so your docker-compose.yml file still looks like this?

...
  mautic_web:
    image: mautic/mautic:5-apache
    links:
      - db:mysql
    ports:
      - 8001:80
    volumes: *mautic-volumes

    environment:
      - DOCKER_MAUTIC_LOAD_TEST_DATA=${DOCKER_MAUTIC_LOAD_TEST_DATA}
      - DOCKER_MAUTIC_RUN_MIGRATIONS=${DOCKER_MAUTIC_RUN_MIGRATIONS}
    env_file:
      - .mautic_env
...

no, i' was forced to add those to get it works so the compose have the extra lines

seems that is a docker default network issue, if I create manually a docker network and attach it to the containers in the compose, it's working.....it's very strange

@devilmind81 that's really strange.
It makes sense to have a separate network (I'll add such solution the the examples), but that should not influence loading the env vars.

Would you be willing to test the same steps as in the previous post, but without adding the extra lines to the environment part?

I want to see if the var loaded via the env_file property are present in the output of that command, as they should.

I restored the original docker file, without extra lines, seems are present but not working:

$ docker compose config --no-path-resolution --no-normalize --format=json mautic_web | jq .ser
vices.mautic_web.environment
{
"DOCKER_MAUTIC_LOAD_TEST_DATA": "false",
"DOCKER_MAUTIC_RUN_MIGRATIONS": "false",
"MAUTIC_DB_DATABASE": "mautic_db",
"MAUTIC_DB_HOST": "db",
"MAUTIC_DB_PASSWORD": "mautic_db_pwd",
"MAUTIC_DB_PORT": "3306",
"MAUTIC_DB_USER": "mautic_db_user",
"MAUTIC_MESSENGER_DSN_EMAIL": "doctrine://default",
"MAUTIC_MESSENGER_DSN_HIT": "doctrine://default"
}

I see that in the web container logs:

mysqladmin: connect to server at '' failed
error: 'Can't connect to server on 'localhost' (99)'
Check that mariadbd is running and that the socket: '/run/mysqld/mysqld.sock' exists!

@devilmind81
You're most likely using docker-compose (v1) instead of docker compose (v2)
Can you retry using docker compose?

@mollux you are right!
using docker compose (v2) is working as expected.
Thanks a lot for the support!