In Azure "Web App for Containers" service I have the following docker-compose.yml file. Based on this: https://github.com/bitnami/bitnami-docker-moodle/blob/master/3/debian-11/docker-compose.yml
version: '2'
services:
mariadb:
image: bitnami/mariadb:10.6
environment:
- MARIADB_USER=bn_moodle
- MARIADB_PASSWORD=foobar1111
- MARIADB_ROOT_PASSWORD=foobar1111
- MARIADB_DATABASE=bitnami_moodle
- MARIADB_CHARACTER_SET=utf8mb4
- MARIADB_COLLATE=utf8mb4_unicode_ci
volumes:
- 'mariadb_data:/bitnami/mariadb'
moodle:
image: bitnami/moodle:3
environment:
- BITNAMI_DEBUG=true
- MOODLE_DATABASE_HOST=mariadb
- MOODLE_DATABASE_PORT_NUMBER=3306
- MOODLE_DATABASE_USER=bn_moodle
- MOODLE_DATABASE_NAME=bitnami_moodle
- MOODLE_DATABASE_PASSWORD=foobar1111
- MOODLE_DATABASE_ROOT_PASSWORD=foobar1111
- MOODLE_SITE_NAME=Moodle v3 Test 1
- MOODLE_USERNAME=foobar_user
- MOODLE_PASSWORD=foobar1111
volumes:
- 'moodle_data:/bitnami/moodle'
- 'moodledata_data:/bitnami/moodledata'
depends_on:
- mariadb
volumes:
mariadb_data:
driver: local
moodle_data:
driver: local
moodledata_data:
driver: local
When I start the service and and inspect the logs I see that the Moodle image is having a hard time accessing the mariadb image. Below is the full dump of the logs. Sorry for the length of this, but I am hoping that someone will be able to recognize a detail within this that may shed light on what is happening.
2022-08-03T21:00:16.439123068Z 2022-08-03 21:00:16 93 [Warning] Aborted connection 93 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:17.521479030Z 2022-08-03 21:00:17 94 [Warning] Aborted connection 94 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:18.581491876Z 2022-08-03 21:00:18 95 [Warning] Aborted connection 95 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:19.663574884Z 2022-08-03 21:00:19 96 [Warning] Aborted connection 96 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:20.707537733Z 2022-08-03 21:00:20 97 [Warning] Aborted connection 97 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:21.852634128Z 2022-08-03 21:00:21 98 [Warning] Aborted connection 98 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:22.928465477Z 2022-08-03 21:00:22 99 [Warning] Aborted connection 99 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:24.016558849Z 2022-08-03 21:00:23 100 [Warning] Aborted connection 100 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:25.470200759Z 2022-08-03 21:00:25 101 [Warning] Aborted connection 101 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:26.539066866Z 2022-08-03 21:00:26 102 [Warning] Aborted connection 102 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:27.555060538Z 2022-08-03 21:00:27 103 [Warning] Aborted connection 103 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:28.738963126Z 2022-08-03 21:00:28 104 [Warning] Aborted connection 104 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:30.332358501Z 2022-08-03 21:00:30 105 [Warning] Aborted connection 105 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:31.727591512Z 2022-08-03 21:00:31 106 [Warning] Aborted connection 106 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:33.470704078Z 2022-08-03 21:00:33 107 [Warning] Aborted connection 107 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:34.448130283Z 2022-08-03 21:00:34 108 [Warning] Aborted connection 108 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:35.461661803Z 2022-08-03 21:00:35 109 [Warning] Aborted connection 109 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:36.487652089Z 2022-08-03 21:00:36 110 [Warning] Aborted connection 110 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:37.517595106Z 2022-08-03 21:00:37 111 [Warning] Aborted connection 111 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:38.584427503Z 2022-08-03 21:00:38 112 [Warning] Aborted connection 112 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:39.610105028Z 2022-08-03 21:00:39 113 [Warning] Aborted connection 113 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:40.646019026Z 2022-08-03 21:00:40 114 [Warning] Aborted connection 114 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:41.644863168Z 2022-08-03 21:00:41 115 [Warning] Aborted connection 115 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:42.660142054Z 2022-08-03 21:00:42 116 [Warning] Aborted connection 116 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:43.711739776Z 2022-08-03 21:00:43 117 [Warning] Aborted connection 117 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:44.709783446Z 2022-08-03 21:00:44 118 [Warning] Aborted connection 118 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:45.732673758Z 2022-08-03 21:00:45 119 [Warning] Aborted connection 119 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:46.762388450Z 2022-08-03 21:00:46 120 [Warning] Aborted connection 120 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:47.758876853Z 2022-08-03 21:00:47 121 [Warning] Aborted connection 121 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:48.776094540Z 2022-08-03 21:00:48 122 [Warning] Aborted connection 122 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:50.340782878Z 2022-08-03 21:00:50 123 [Warning] Aborted connection 123 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:55.361470046Z 2022-08-03 21:00:55 124 [Warning] Aborted connection 124 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:56.388063845Z 2022-08-03 21:00:56 125 [Warning] Aborted connection 125 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:57.421708836Z 2022-08-03 21:00:57 126 [Warning] Aborted connection 126 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:58.437290366Z 2022-08-03 21:00:58 127 [Warning] Aborted connection 127 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:00:59.447538290Z 2022-08-03 21:00:59 128 [Warning] Aborted connection 128 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:01:00.493517915Z 2022-08-03 21:01:00 129 [Warning] Aborted connection 129 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:01:01.505069338Z 2022-08-03 21:01:01 130 [Warning] Aborted connection 130 to db: 'unconnected' user: 'unauthenticated' host: '172.16.24.1' (This connection closed normally without authentication)
2022-08-03T21:01:06.794Z INFO - Container logs from moodlev3-docker-1_moodle_0_8777f90c = 2022-08-03T20:57:20.591495328Z [38;5;6mmoodle [38;5;5m20:57:20.59 [0m
2022-08-03T20:57:20.609727111Z [38;5;6mmoodle [38;5;5m20:57:20.60 [0m[1mWelcome to the Bitnami moodle container[0m
2022-08-03T20:57:20.620203620Z [38;5;6mmoodle [38;5;5m20:57:20.61 [0mSubscribe to project updates by watching [1mhttps://github.com/bitnami/containers[0m
2022-08-03T20:57:20.647346277Z [38;5;6mmoodle [38;5;5m20:57:20.64 [0mSubmit issues and feature requests at [1mhttps://github.com/bitnami/containers/issues[0m
2022-08-03T20:57:20.666697957Z [38;5;6mmoodle [38;5;5m20:57:20.66 [0m
2022-08-03T20:57:20.686110642Z [38;5;6mmoodle [38;5;5m20:57:20.68 [0m[38;5;2mINFO [0m ==> ** Starting Moodle setup **
2022-08-03T20:57:20.872220400Z [38;5;6mmoodle [38;5;5m20:57:20.85 [0m[38;5;5mDEBUG[0m ==> Validating settings in APACHE_* environment variables
2022-08-03T20:57:21.326406628Z realpath: /bitnami/apache/conf: No such file or directory
2022-08-03T20:57:21.355210529Z [38;5;6mmoodle [38;5;5m20:57:21.33 [0m[38;5;2mINFO [0m ==> Configuring Apache ServerTokens directive
2022-08-03T20:57:21.366166280Z [38;5;6mmoodle [38;5;5m20:57:21.36 [0m[38;5;5mDEBUG[0m ==> Configuring ServerTokens Prod on file /opt/bitnami/apache/conf/httpd.conf
2022-08-03T20:57:21.868867817Z [38;5;6mmoodle [38;5;5m20:57:21.86 [0m[38;5;2mINFO [0m ==> Configuring PHP options
2022-08-03T20:57:21.887165406Z [38;5;6mmoodle [38;5;5m20:57:21.88 [0m[38;5;2mINFO [0m ==> Setting PHP expose_php option
2022-08-03T20:57:22.109567044Z [38;5;6mmoodle [38;5;5m20:57:22.10 [0m[38;5;2mINFO [0m ==> Validating settings in MYSQL_CLIENT_* env vars
2022-08-03T20:57:22.200697195Z [38;5;6mmoodle [38;5;5m20:57:22.19 [0m[38;5;2mINFO [0m ==> Validating settings in POSTGRESQL_CLIENT_* env vars
2022-08-03T20:57:22.390634457Z [38;5;6mmoodle [38;5;5m20:57:22.38 [0m[38;5;5mDEBUG[0m ==> Validating settings in MOODLE_* environment variables...
2022-08-03T20:57:22.762741913Z [38;5;6mmoodle [38;5;5m20:57:22.76 [0m[38;5;2mINFO [0m ==> Ensuring Moodle directories exist
2022-08-03T20:57:23.111049117Z [38;5;6mmoodle [38;5;5m20:57:23.11 [0m[38;5;2mINFO [0m ==> Trying to connect to the database server
2022-08-03T20:57:23.139873300Z [38;5;6mmoodle [38;5;5m20:57:23.13 [0m[38;5;5mDEBUG[0m ==> Executing SQL command:
2022-08-03T20:57:23.148274123Z SELECT 1
2022-08-03T20:57:23.618638938Z ERROR 2002 (HY000): Can't connect to server on 'mariadb' (115)
2022-08-03T20:57:28.736342289Z [38;5;6mmoodle [38;5;5m20:57:28.73 [0m[38;5;5mDEBUG[0m ==> Executing SQL command:
2022-08-03T20:57:28.737759302Z SELECT 1
2022-08-03T20:57:28.776248773Z ERROR 2002 (HY000): Can't connect to server on 'mariadb' (115)
2022-08-03T20:57:33.807767194Z [38;5;6mmoodle [38;5;5m20:57:33.80 [0m[38;5;5mDEBUG[0m ==> Executing SQL command:
2022-08-03T20:57:33.845294560Z SELECT 1
2022-08-03T20:57:33.871246387Z ERROR 2002 (HY000): Can't connect to server on 'mariadb' (115)
2022-08-03T20:57:38.914237527Z [38;5;6mmoodle [38;5;5m20:57:38.91 [0m[38;5;5mDEBUG[0m ==> Executing SQL command:
2022-08-03T20:57:38.915290320Z SELECT 1
2022-08-03T20:57:38.943604825Z ERROR 2002 (HY000): Can't connect to server on 'mariadb' (115)
2022-08-03T20:57:43.976763752Z [38;5;6mmoodle [38;5;5m20:57:43.97 [0m[38;5;5mDEBUG[0m ==> Executing SQL command:
2022-08-03T20:57:43.977475015Z SELECT 1
2022-08-03T20:57:44.006532384Z ERROR 2002 (HY000): Can't connect to server on 'mariadb' (115)
2022-08-03T20:57:49.156310564Z [38;5;6mmoodle [38;5;5m20:57:49.14 [0m[38;5;5mDEBUG[0m ==> Executing SQL command:
2022-08-03T20:57:49.157092733Z SELECT 1
2022-08-03T20:57:49.265267210Z ERROR 2002 (HY000): Can't connect to server on 'mariadb' (115)
2022-08-03T20:57:54.328419472Z [38;5;6mmoodle [38;5;5m20:57:54.32 [0m[38;5;5mDEBUG[0m ==> Executing SQL command:
2022-08-03T20:57:54.329748383Z SELECT 1
2022-08-03T20:57:54.376230493Z ERROR 2002 (HY000): Can't connect to server on 'mariadb' (115)
2022-08-03T20:57:59.404119697Z [38;5;6mmoodle [38;5;5m20:57:59.40 [0m[38;5;5mDEBUG[0m ==> Executing SQL command:
2022-08-03T20:57:59.406432892Z SELECT 1
2022-08-03T20:57:59.441740060Z ERROR 2002 (HY000): Can't connect to server on 'mariadb' (115)
2022-08-03T20:58:04.474194391Z [38;5;6mmoodle [38;5;5m20:58:04.47 [0m[38;5;5mDEBUG[0m ==> Executing SQL command:
2022-08-03T20:58:04.474852346Z SELECT 1
2022-08-03T20:58:04.502372933Z ERROR 2002 (HY000): Can't connect to server on 'mariadb' (115)
2022-08-03T20:58:09.526378548Z [38;5;6mmoodle [38;5;5m20:58:09.52 [0m[38;5;5mDEBUG[0m ==> Executing SQL command:
2022-08-03T20:58:09.527644953Z SELECT 1
2022-08-03T20:58:09.564180782Z ERROR 2002 (HY000): Can't connect to server on 'mariadb' (115)
2022-08-03T20:58:14.595786711Z [38;5;6mmoodle [38;5;5m20:58:14.59 [0m[38;5;5mDEBUG[0m ==> Executing SQL command:
2022-08-03T20:58:14.596793094Z SELECT 1
2022-08-03T20:58:14.626229833Z ERROR 2002 (HY000): Can't connect to server on 'mariadb' (115)
2022-08-03T20:58:19.693104850Z [38;5;6mmoodle [38;5;5m20:58:19.69 [0m[38;5;5mDEBUG[0m ==> Executing SQL command:
2022-08-03T20:58:19.693972122Z SELECT 1
2022-08-03T20:58:19.751356195Z ERROR 2002 (HY000): Can't connect to server on 'mariadb' (115)
2022-08-03T20:58:24.778342010Z [38;5;6mmoodle [38;5;5m20:58:24.77 [0m[38;5;1mERROR[0m ==> Could not connect to the database
2022-08-03T20:58:32.265779242Z [38;5;6mmoodle [38;5;5m20:58:32.25 [0m
2022-08-03T20:58:32.265811645Z [38;5;6mmoodle [38;5;5m20:58:32.26 [0m[1mWelcome to the Bitnami moodle container[0m
2022-08-03T20:58:32.362755163Z [38;5;6mmoodle [38;5;5m20:58:32.27 [0mSubscribe to project updates by watching [1mhttps://github.com/bitnami/containers[0m
2022-08-03T20:58:32.362791267Z [38;5;6mmoodle [38;5;5m20:58:32.28 [0mSubmit issues and feature requests at [1mhttps://github.com/bitnami/containers/issues[0m
2022-08-03T20:58:32.362797567Z [38;5;6mmoodle [38;5;5m20:58:32.29 [0m
2022-08-03T20:58:32.362802167Z [38;5;6mmoodle [38;5;5m20:58:32.30 [0m[38;5;2mINFO [0m ==> ** Starting Moodle setup **
2022-08-03T20:58:32.381449467Z [38;5;6mmoodle [38;5;5m20:58:32.37 [0m[38;5;5mDEBUG[0m ==> Validating settings in APACHE_* environment variables
2022-08-03T20:58:32.585382466Z realpath: /bitnami/apache/conf: No such file or directory
2022-08-03T20:58:32.602522037Z [38;5;6mmoodle [38;5;5m20:58:32.60 [0m[38;5;2mINFO [0m ==> Configuring Apache ServerTokens directive
2022-08-03T20:58:32.613771302Z [38;5;6mmoodle [38;5;5m20:58:32.61 [0m[38;5;5mDEBUG[0m ==> Configuring ServerTokens Prod on file /opt/bitnami/apache/conf/httpd.conf
2022-08-03T20:58:32.839203521Z [38;5;6mmoodle [38;5;5m20:58:32.83 [0m[38;5;2mINFO [0m ==> Configuring PHP options
2022-08-03T20:58:32.858137102Z [38;5;6mmoodle [38;5;5m20:58:32.85 [0m[38;5;2mINFO [0m ==> Setting PHP expose_php option
2022-08-03T20:58:33.084887121Z [38;5;6mmoodle [38;5;5m20:58:33.08 [0m[38;5;2mINFO [0m ==> Validating settings in MYSQL_CLIENT_* env vars
2022-08-03T20:58:33.133969776Z [38;5;6mmoodle [38;5;5m20:58:33.13 [0m[38;5;2mINFO [0m ==> Validating settings in POSTGRESQL_CLIENT_* env vars
2022-08-03T20:58:33.402267480Z [38;5;6mmoodle [38;5;5m20:58:33.39 [0m[38;5;5mDEBUG[0m ==> Validating settings in MOODLE_* environment variables...
2022-08-03T20:58:33.698535666Z [38;5;6mmoodle [38;5;5m20:58:33.69 [0m[38;5;2mINFO [0m ==> Ensuring Moodle directories exist
2022-08-03T20:58:33.951847841Z [38;5;6mmoodle [38;5;5m20:58:33.95 [0m[38;5;2mINFO [0m ==> Trying to connect to the database server
2022-08-03T20:58:33.988771717Z [38;5;6mmoodle [38;5;5m20:58:33.98 [0m[38;5;5mDEBUG[0m ==> Executing SQL command:
2022-08-03T20:58:33.996028561Z SELECT 1
2022-08-03T20:58:34.185064474Z ERROR 2002 (HY000): Can't connect to server on 'mariadb' (115)
2022-08-03T20:58:39.220559645Z [38;5;6mmoodle [38;5;5m20:58:39.21 [0m[38;5;5mDEBUG[0m ==> Executing SQL command:
2022-08-03T20:58:39.228124917Z SELECT 1
2022-08-03T20:58:39.259267085Z ERROR 2002 (HY000): Can't connect to server on 'mariadb' (115)
2022-08-03T20:58:44.291723055Z [38;5;6mmoodle [38;5;5m20:58:44.28 [0m[38;5;5mDEBUG[0m ==> Executing SQL command:
2022-08-03T20:58:44.293894037Z SELECT 1
2022-08-03T20:58:44.322373229Z ERROR 2002 (HY000): Can't connect to server on 'mariadb' (115)
2022-08-03T20:58:49.353190272Z [38;5;6mmoodle [38;5;5m20:58:49.35 [0m[38;5;5mDEBUG[0m ==> Executing SQL command:
2022-08-03T20:58:49.353798324Z SELECT 1
2022-08-03T20:58:49.408754680Z 1
2022-08-03T20:58:49.421740880Z [38;5;6mmoodle [38;5;5m20:58:49.42 [0m[38;5;2mINFO [0m ==> Running Moodle install script
2022-08-03T20:58:51.422292640Z .-..-.
2022-08-03T20:58:51.422335744Z _____ | || |
2022-08-03T20:58:51.422343245Z /____/-.---_ .---. .---. .-.| || | .---.
2022-08-03T20:58:51.422348945Z | | _ _ |/ _ \/ _ \/ _ || |/ __ \
2022-08-03T20:58:51.422354446Z * | | | | | || |_| || |_| || |_| || || |___/
2022-08-03T20:58:51.422359746Z |_| |_| |_|\_____/\_____/\_____||_|\_____)
2022-08-03T20:58:51.425938649Z
2022-08-03T20:58:51.425988453Z Moodle 3.11.8 (Build: 20220711) command line installation program
2022-08-03T20:58:52.928214968Z -->System
2022-08-03T21:01:14.435Z INFO - Stopping site moodlev3-docker-1 because it failed during startup.
Any thoughts as to why this is failing during startup? I expect the issue is credentials as supplied through the environment variables but this same configuration has worked locally and on AWS.
Edit your Compose file with these modifications: remove driver: local from each volume and set the port that the mariadb service is listening on.
version: '3'
services:
mariadb:
image: bitnami/mariadb:10.6
ports:
- "3306"
environment:
- MARIADB_USER=bn_moodle
- MARIADB_PASSWORD=foobar1111
- MARIADB_ROOT_PASSWORD=foobar1111
- MARIADB_DATABASE=bitnami_moodle
- MARIADB_CHARACTER_SET=utf8mb4
- MARIADB_COLLATE=utf8mb4_unicode_ci
volumes:
- 'mariadb_data:/bitnami/mariadb'
moodle:
image: bitnami/moodle:3
environment:
- BITNAMI_DEBUG=true
- MOODLE_DATABASE_HOST=mariadb
- MOODLE_DATABASE_PORT_NUMBER=3306
- MOODLE_DATABASE_USER=bn_moodle
- MOODLE_DATABASE_NAME=bitnami_moodle
- MOODLE_DATABASE_PASSWORD=foobar1111
- MOODLE_DATABASE_ROOT_PASSWORD=foobar1111
- MOODLE_SITE_NAME=Moodle v3 Test 1
- MOODLE_USERNAME=foobar_user
- MOODLE_PASSWORD=foobar1111
volumes:
- 'moodle_data:/bitnami/moodle'
- 'moodledata_data:/bitnami/moodledata'
depends_on:
- mariadb
volumes:
mariadb_data:
moodle_data:
moodledata_data:
Related
I develop a web-app using Flask under Python3. I have a problem with connecting to postgresql via sqlalchemy.
Dockerfile:
FROM ubuntu:20.04
ENV LANG en_US.UTF-8
RUN apt update
RUN apt install -y python3-pip python3.8-dev
RUN apt install default-libmysqlclient-dev -y
RUN apt install libpq-dev -y
WORKDIR /app
ADD ./requirements.txt /app/requirements.txt
RUN pip3 install psycopg2
RUN --mount=type=cache,target=/root/.cache/pip pip3 install -r requirements.txt
RUN pip3 install -r requirements.txt
COPY . /app
ENV PYTHONPATH "${PYTHONPATH}:/app/src"
CMD ["gunicorn", "-c", "python:config.gunicorn", "--worker-class", "aiohttp.worker.GunicornWebWorker", "--pythonpath", "/app/src/", "src.main:app"]
docker-compose.yml:
services:
backend:
environment:
TZ: 'UTC'
volumes:
- ./src:/app/src
build:
context: .
restart: always
ports:
- '80:5000'
depends_on:
- postgres
links:
- postgres:postgres
postgres:
restart: always
image: postgres:latest
volumes:
- /var/lib/postgresql
environment:
POSTGRES_PASSWORD: 1234
POSTGRES_USER: postgres
POSTGRES_DB: postgres
POSTGRES_INITDB_ARGS: "-A md5"
ports:
- "5432:5432"
Postgresql logs:
2022-08-03 14:21:46.773 UTC [1] LOG: starting PostgreSQL 14.4 (Debian 14.4-1.pgdg110+1) on aarch64-unknown-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2022-08-03 14:21:46.776 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2022-08-03 14:21:46.776 UTC [1] LOG: listening on IPv6 address "::", port 5432
2022-08-03 14:21:46.781 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2022-08-03 14:21:46.787 UTC [27] LOG: database system was shut down at 2022-08-03 14:20:52 UTC
2022-08-03 14:21:46.794 UTC [1] LOG: database system is ready to accept connections
2022-08-03 14:21:50.342 UTC [1] LOG: received fast shutdown request
2022-08-03 14:21:50.344 UTC [1] LOG: aborting any active transactions
2022-08-03 14:21:50.347 UTC [1] LOG: background worker "logical replication launcher" (PID 33) exited with exit code 1
2022-08-03 14:21:50.347 UTC [28] LOG: shutting down
2022-08-03 14:21:50.365 UTC [1] LOG: database system is shut down
Python app logs:
sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) could not connect to server: Connection refused
Is the server running on host "0.0.0.0" and accepting
TCP/IP connections on port 5432?
As you can see postgresql is running on 0.0.0.0:5432 and sqlalchemy tries to connect to 0.0.0.0:5432. Therefore, it is not very clear what it does not like.
If I remember correctly, when connecting to another service within a docker compose network, you have to connect using the service name as the host name - so postgres:5432 in your case.
I'm getting this error when i try to connect my fabric-ca to use postgres as a database.
Using postgres database, connecting to database...
2019/10/22 09:21:16 [DEBUG] Database Name: fabriccaserver
2019/10/22 09:21:16 [DEBUG] Connecting to PostgreSQL server, using connection string: host=127.0.0.1 port=5432 user=**** password=**** dbname=fabriccaserver sslmode=disable
2019/10/22 09:21:16 [WARNING] Failed to connect to database 'fabriccaserver'
2019/10/22 09:21:16 [DEBUG] Connecting to PostgreSQL server, using connection string: host=127.0.0.1 port=5432 user=**** password=**** dbname=postgres sslmode=disable
2019/10/22 09:21:16 [WARNING] Failed to connect to database 'postgres'
2019/10/22 09:21:16 [DEBUG] Connecting to PostgreSQL server, using connection string: host=127.0.0.1 port=5432 user=**** password=**** dbname=template1 sslmode=disable
2019/10/22 09:21:16 [WARNING] Failed to connect to database 'template1'
2019/10/22 09:21:16 [ERROR] Error occurred initializing database: Failed to connect to Postgres database. Postgres requires connecting to a specific database, the following databases were tried: [fabriccaserver postgres template1]. Please create one of these database before continuing
I solved this error by putting container_name in the host i,e.
db:
db:
type: postgres
datasource: host=db-postgres port=5432 user=postgres password=caDbPass12345 dbname=fabriccaserver sslmode=disable
tls:
enabled: false
certfiles:
client:
certfile:
keyfile:
Previously, i was entering localhost and also tried with 127.0.0.1 and after that i saw that in my docker-compose.yaml my postgres service was under different network and ica.org1.example.com was under different network which i fixed and also had to do docker network prune after killing and removing all the docker processes.
I deployed my nodejs 10.16.3 app to ubuntu 18.04 from my win10 PC development. After starting the app with pm2 start /ebs/myapp/index.js on ubuntu, there is an error about sequelize (5.19.1) database connection:
$cat index-error.log
Unable to connect to the database: { SequelizeConnectionRefusedError: connect ECONNREFUSED 127.0.0.1:5433
at connection.connect.err (/ebs/myapp/node_modules/sequelize/lib/dialects/postgres/connection-manager.js:170:24)
at Connection.connectingErrorHandler (/ebs/myapp/node_modules/pg/lib/client.js:174:14)
at Connection.emit (events.js:198:13)
at Socket.reportStreamError (/ebs/myapp/node_modules/pg/lib/connection.js:72:10)
at Socket.emit (events.js:198:13)
at emitErrorNT (internal/streams/destroy.js:91:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
at process._tickCallback (internal/process/next_tick.js:63:19)
name: 'SequelizeConnectionRefusedError',
parent:
{ Error: connect ECONNREFUSED 127.0.0.1:5433
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1106:14)
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 5433 },
original:
{ Error: connect ECONNREFUSED 127.0.0.1:5433
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1106:14)
errno: 'ECONNREFUSED',
code: 'ECONNREFUSED',
syscall: 'connect',
address: '127.0.0.1',
port: 5433 } }
The postgres (11.5) is running on the same host and I can access it via command line with success.
pm2 log file also indicates that the nodejs app is listening on port 3000. This app front is a nginx reverse proxy which likely has nothing to do with this error.
Here is the db connection string:
const Sql = require("sequelize");
const db = new Sql('mydb', 'postgres', `${process.env.DB_PASSWORD}`, {
host: 'localhost',
dialect: 'postgres',
port:5433,
} );
Why the sequelize connection is refused?
Update: postgresql log:
$ cat postgresql-11-main.log
2019-10-07 20:24:27.712 UTC [665] postgres#emps ERROR: syntax error at or near "psql" at character 1
2019-10-07 20:24:27.712 UTC [665] postgres#emps STATEMENT: psql
;
ubuntu#:/var/log/postgresql$ cat postgresql-11-main.log.1
2019-10-04 09:10:49.214 UTC [22809] LOG: received fast shutdown request
2019-10-04 09:10:49.221 UTC [22809] LOG: aborting any active transactions
2019-10-04 09:10:49.292 UTC [22809] LOG: background worker "logical replication launcher" (PID 22816) exited with exit code 1
2019-10-04 09:10:49.298 UTC [22811] LOG: shutting down
2019-10-04 09:10:49.435 UTC [22809] LOG: database system is shut down
2019-10-04 09:11:11.561 UTC [1084] LOG: listening on IPv4 address "127.0.0.1", port 5432
2019-10-04 09:11:11.567 UTC [1084] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2019-10-04 09:11:11.628 UTC [1096] LOG: database system was shut down at 2019-10-04 09:10:49 UTC
2019-10-04 09:11:11.648 UTC [1084] LOG: database system is ready to accept connections
2019-10-04 09:11:12.196 UTC [1134] [unknown]#[unknown] LOG: incomplete startup packet
2019-10-04 09:11:17.827 UTC [1282] [unknown]#[unknown] LOG: incomplete startup packet
2019-10-04 09:13:42.106 UTC [1084] LOG: received fast shutdown request
2019-10-04 09:13:42.110 UTC [1084] LOG: aborting any active transactions
2019-10-04 09:13:42.114 UTC [1084] LOG: background worker "logical replication launcher" (PID 1102) exited with exit code 1
2019-10-04 09:13:42.115 UTC [1097] LOG: shutting down
2019-10-04 09:13:42.138 UTC [1084] LOG: database system is shut down
2019-10-04 09:13:46.533 UTC [3040] LOG: listening on IPv4 address "127.0.0.1", port 5432
2019-10-04 09:13:46.535 UTC [3040] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2019-10-04 09:13:46.566 UTC [3041] LOG: database system was shut down at 2019-10-04 09:13:42 UTC
2019-10-04 09:13:46.577 UTC [3040] LOG: database system is ready to accept connections
2019-10-04 09:13:47.110 UTC [3048] [unknown]#[unknown] LOG: incomplete startup packet
2019-10-04 09:13:52.713 UTC [3082] [unknown]#[unknown] LOG: incomplete startup packet
The logs of your PostgreSQL server say that it is launched at the default port 5432. But in your app you'r trying to connect to 5433.
Try this connection instead:
const Sql = require("sequelize");
const db = new Sql('mydb', 'postgres', `${process.env.DB_PASSWORD}`, {
host: 'localhost',
dialect: 'postgres',
port: 5432, // instead of 5433
} );
I'm trying to access a postgresql docker container through DBeaver, but I can't figure out how to make it work.
Running docker port db_1 returns:
5432/tcp -> 0.0.0.0:5432
So the port should be open to connections.
The postgresql.conf is set to
listen_addresses = '*'
Running docker inspect --format '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' db_1 returns
172.19.0.2
When trying to connect to the database to either localhost / 127.0.0.1 / 172.19.0.2 / db_1 the Dbeaver log returns this:
2019-03-18 17:22:03.000 - Connect with 'jdbc:postgresql://db_1:5432/test' (postgres-jdbc-169919c23d5-77ac021a71307fee)
....
2019-03-18 17:22:14.815 - SSH INFO: SSH_MSG_SERVICE_ACCEPT received
2019-03-18 17:22:14.824 - SSH INFO: Authentications that can continue: password,keyboard-interactive
2019-03-18 17:22:14.825 - SSH INFO: Next authentication method: password
2019-03-18 17:22:18.432 - SSH INFO: Authentication succeeded (password).
2019-03-18 17:22:18.458 - Connection failed (postgres-jdbc-169919c23d5-77ac021a71307fee)
2019-03-18 17:22:18.459 - SSH INFO: Disconnecting from domain.com port 22
2019-03-18 17:22:18.461 - SSH INFO: Caught an exception, leaving main loop due to Socket closed
2019-03-18 17:22:18.514 - org.jkiss.dbeaver.model.exec.DBCConnectException: The connection attempt failed.
org.jkiss.dbeaver.model.exec.DBCConnectException: The connection attempt failed.
at org.jkiss.dbeaver.model.impl.jdbc.JDBCDataSource.openConnection(JDBCDataSource.java:179)
at org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource.openConnection(PostgreDataSource.java:363)
at org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource.initializeRemoteInstance(PostgreDataSource.java:122)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCDataSource.<init>(JDBCDataSource.java:100)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCDataSource.<init>(JDBCDataSource.java:89)
at org.jkiss.dbeaver.ext.postgresql.model.PostgreDataSource.<init>(PostgreDataSource.java:80)
at org.jkiss.dbeaver.ext.postgresql.PostgreDataSourceProvider.openDataSource(PostgreDataSourceProvider.java:97)
at org.jkiss.dbeaver.registry.DataSourceDescriptor.connect(DataSourceDescriptor.java:770)
at org.jkiss.dbeaver.runtime.jobs.ConnectJob.run(ConnectJob.java:70)
at org.jkiss.dbeaver.ui.dialogs.connection.ConnectionWizard$ConnectionTester.run(ConnectionWizard.java:232)
at org.jkiss.dbeaver.model.runtime.AbstractJob.run(AbstractJob.java:101)
at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
Caused by: org.postgresql.util.PSQLException: The connection attempt failed.
at org.postgresql.Driver$ConnectThread.getResult(Driver.java:405)
at org.postgresql.Driver.connect(Driver.java:263)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCDataSource.lambda$0(JDBCDataSource.java:148)
at org.jkiss.dbeaver.model.impl.jdbc.JDBCDataSource.openConnection(JDBCDataSource.java:157)
... 11 more
Caused by: java.net.SocketException: Connection reset
at java.net.SocketInputStream.read(SocketInputStream.java:210)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at org.postgresql.core.VisibleBufferedInputStream.readMore(VisibleBufferedInputStream.java:140)
at org.postgresql.core.VisibleBufferedInputStream.ensureBytes(VisibleBufferedInputStream.java:109)
at org.postgresql.core.VisibleBufferedInputStream.read(VisibleBufferedInputStream.java:67)
at org.postgresql.core.PGStream.receiveChar(PGStream.java:306)
at org.postgresql.core.v3.ConnectionFactoryImpl.enableSSL(ConnectionFactoryImpl.java:405)
at org.postgresql.core.v3.ConnectionFactoryImpl.tryConnect(ConnectionFactoryImpl.java:94)
at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:192)
at org.postgresql.core.ConnectionFactory.openConnection(ConnectionFactory.java:49)
at org.postgresql.jdbc.PgConnection.<init>(PgConnection.java:195)
at org.postgresql.Driver.makeConnection(Driver.java:454)
at org.postgresql.Driver.access$100(Driver.java:57)
at org.postgresql.Driver$ConnectThread.run(Driver.java:364)
at java.lang.Thread.run(Thread.java:748)
Really clueless on how to make the connection work. The SSH tunnel obviously works, but the connection to the db fails. I have a spring boot application running in another container, and connecting that through the connection string jdbc:postgresql://db_1:5432/test works like a charm.
Any input on this? Could it be that 0.0.0.0 doesn't get mapped to the internal network somehow?
How are you exactly running your container, I suspect maybe you are missing to expose the ports? because I just tried running a postgres instance using the following command in PS:
docker run --name some-postgres -e POSTGRES_PASSWORD=mysecretpassword -d -p 5433:5432 postgres
Mapping the default postgres container port 5432 to my local 5433 port (because I have a postgres installation locally and didn't want to run into some kind of port-interferance problem) and later on created a database by accessing the docker and running some psql commands as described on this answer and then accesed the DB from DBeaver
and everything worked fine! Hope this helps.
I'm trying to get redis running locally. It works fine sometimes, but sometimes I have this problem when starting it. It appears to start fine, but then I can't make any connections to it or use the command line tool. I can't understand why there would be no errors when starting redis, it says its running on 6379, but won't respond on that port.
Toms-MBP:tinder-art tomchambers$ redis-server
[86521] 23 Apr 18:37:22.427 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
[86521] 23 Apr 18:37:22.429 * Increased maximum number of open files to 10032 (it was originally set to 256).
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 2.8.19 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in stand alone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 86521
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | http://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
[86521] 23 Apr 18:37:22.431 # Server started, Redis version 2.8.19
[86521] 23 Apr 18:37:22.432 * DB loaded from disk: 0.000 seconds
[86521] 23 Apr 18:37:22.432 * The server is now ready to accept connections on port 6379
Toms-MBP:tinder-art tomchambers$ redis-cli monitor
Error: Server closed the connection
^CToms-MBP:tinder-art tomchambers$ node app.js
Connecting to local redis
Connecting to local redis
Server started 3000
Redis error: [Error: Ready check failed: Redis connection to 127.0.0.1:6379 failed - read ECONNRESET]
Redis error: [Error: Redis connection to 127.0.0.1:6379 failed - read ECONNRESET]
Redis error: [Error: Ready check failed: Redis connection to 127.0.0.1:6379 failed - read ECONNRESET]
Redis error: [Error: Redis connection to 127.0.0.1:6379 failed - read ECONNRESET]
Redis error: [Error: Ready check failed: Redis connection gone from end event.]
Redis error: [Error: Ready check failed: Redis connection gone from end event.]
Redis error: [Error: Ready check failed: Redis connection gone from end event.]
Redis error: [Error: Ready check failed: Redis connection gone from end event.]
Redis error: [Error: Ready check failed: Redis connection gone from end event.]