mautic / docker-mautic

Docker Image for Mautic
https://www.mautic.org
370 stars 278 forks source link

Basic Docker compose Environment Variable issues #257

Closed devilmind81 closed 7 months ago

devilmind81 commented 8 months ago

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

mollux commented 8 months ago

@devilmind81

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

devilmind81 commented 8 months ago

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
mollux commented 8 months ago

@devilmind81

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

devilmind81 commented 8 months ago

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" }

mollux commented 8 months ago

@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
...
devilmind81 commented 8 months ago

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

devilmind81 commented 8 months ago

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

mollux commented 8 months ago

@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.

devilmind81 commented 8 months ago

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!

mollux commented 7 months ago

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

devilmind81 commented 7 months ago

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