I’m having problems with docker-compose
for a while now and can’t figure out what’s going on there. Given is the following scenario – which worked before but stopped working on a new project and now on every new stack I build up:
$ docker --version
Docker version 20.10.12, build e91ed57
$ docker-compose --version
Docker Compose version v2.2.2
OS: Pop!_OS 21.10 (NVIDIA)
Filestructure:
/myfolder
+ app-src (containing my laravel-project)
+ database-dumps (for database-dumps - containing a .gitkeep-file)
+ database_persist (for persistent data - containing a .gitkeep-file)
- .env
- .gitignore
- buildcontrainer.sh (custom script)
- container-start.sh (custom script)
- docker-compose.yml
- migrate-database.sh (custom script)
- README.md
This is the shortened docker-compose.yml-file
(shortened, because it only affects the database… nginx and the php-container are working fine):
version: '3'
services:
database:
environment:
- MYSQL_DATABASE=${DB_DATABASE}
- MYSQL_USER=${DB_USER}
- MYSQL_PASSWORD=${DB_PASSWORD}
- MYSQL_ROOT_PASSWORD=${DB_ROOT_PASSWORD}
image: mariadb:10.6.1
ports:
- "${DB_EXPOSE_PORT}:3306"
volumes:
- "./database_persist:/var/lib/mysqldata"
And the .env-File:
COMPOSE_PROJECT_NAME=MyProject
DB_DATABASE="myprojectdb"
DB_USER="myproject"
DB_PASSWORD="12345"
DB_ROOT_PASSWORD="12345"
DB_EXPOSE_PORT=9036
WEB_EXPOSE_PORT_HTTP=9080
WEB_EXPOSE_PORT_HTTPS=9043
Now to my problem – whenever I try to set up an environment like given in the scenario and I run docker-compose build
and docker-compose up
afterwards I get the following output:
Creating network "myproject_default" with the default driver
Creating myproject_database_1 ... done
Attaching to myproject_database_1
database_1 | 2021-12-25 15:30:53+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.6.1+maria~focal started.
database_1 | 2021-12-25 15:30:53+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
database_1 | 2021-12-25 15:30:53+00:00 [Note] [Entrypoint]: Entrypoint script for MariaDB Server 1:10.6.1+maria~focal started.
database_1 | 2021-12-25 15:30:53+00:00 [Note] [Entrypoint]: Initializing database files
database_1 | 2021-12-25 15:30:53 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
database_1 |
database_1 |
database_1 | PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
database_1 | To do so, start the server, then issue the following commands:
database_1 |
database_1 | '/usr/bin/mysqladmin' -u root password 'new-password'
database_1 | '/usr/bin/mysqladmin' -u root -h password 'new-password'
database_1 |
database_1 | Alternatively you can run:
database_1 | '/usr/bin/mysql_secure_installation'
database_1 |
database_1 | which will also give you the option of removing the test
database_1 | databases and anonymous user created by default. This is
database_1 | strongly recommended for production servers.
database_1 |
database_1 | See the MariaDB Knowledgebase at https://mariadb.com/kb or the
database_1 | MySQL manual for more instructions.
database_1 |
database_1 | Please report any problems at https://mariadb.org/jira
database_1 |
database_1 | The latest information about MariaDB is available at https://mariadb.org/.
database_1 | You can find additional information about the MySQL part at:
database_1 | https://dev.mysql.com
database_1 | Consider joining MariaDB's strong and vibrant community:
database_1 | https://mariadb.org/get-involved/
database_1 |
database_1 | 2021-12-25 15:30:57+00:00 [Note] [Entrypoint]: Database files initialized
database_1 | 2021-12-25 15:30:57+00:00 [Note] [Entrypoint]: Starting temporary server
database_1 | 2021-12-25 15:30:57+00:00 [Note] [Entrypoint]: Waiting for server startup
database_1 | 2021-12-25 15:30:57 0 [Note] mysqld (mysqld 10.6.1-MariaDB-1:10.6.1+maria~focal) starting as process 110 ...
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: Number of pools: 1
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
database_1 | 2021-12-25 15:30:57 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: Using Linux native AIO
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: Completed initialization of buffer pool
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: 128 rollback segments are active.
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: Creating shared tablespace for temporary tables
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: 10.6.1 started; log sequence number 42616; transaction id 18
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
database_1 | 2021-12-25 15:30:57 0 [Note] Plugin 'FEEDBACK' is disabled.
database_1 | 2021-12-25 15:30:57 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
database_1 | 2021-12-25 15:30:57 0 [Warning] 'user' entry 'root@66d18f02ea8a' ignored in --skip-name-resolve mode.
database_1 | 2021-12-25 15:30:57 0 [Warning] 'proxies_priv' entry '@% root@66d18f02ea8a' ignored in --skip-name-resolve mode.
database_1 | 2021-12-25 15:30:57 0 [Note] InnoDB: Buffer pool(s) load completed at 211225 15:30:57
database_1 | 2021-12-25 15:30:57 0 [Note] mysqld: ready for connections.
database_1 | Version: '10.6.1-MariaDB-1:10.6.1+maria~focal' socket: '/run/mysqld/mysqld.sock' port: 0 mariadb.org binary distribution
database_1 | 2021-12-25 15:30:58+00:00 [Note] [Entrypoint]: Temporary server started.
database_1 | Warning: Unable to load '/usr/share/zoneinfo/leap-seconds.list' as time zone. Skipping it.
database_1 | Warning: Unable to load '/usr/share/zoneinfo/leapseconds' as time zone. Skipping it.
database_1 | Warning: Unable to load '/usr/share/zoneinfo/tzdata.zi' as time zone. Skipping it.
database_1 | 2021-12-25 15:31:01 5 [Warning] 'proxies_priv' entry '@% root@66d18f02ea8a' ignored in --skip-name-resolve mode.
database_1 | 2021-12-25 15:31:01+00:00 [Note] [Entrypoint]: Creating database myprojectdb
database_1 | 2021-12-25 15:31:01+00:00 [Note] [Entrypoint]: Creating user myproject
database_1 | 2021-12-25 15:31:01+00:00 [Note] [Entrypoint]: Giving user myproject access to schema myprojectdb
database_1 |
database_1 | 2021-12-25 15:31:01+00:00 [Note] [Entrypoint]: Stopping temporary server
database_1 | 2021-12-25 15:31:01 0 [Note] mysqld (initiated by: root[root] @ localhost []): Normal shutdown
database_1 | 2021-12-25 15:31:01 0 [Note] InnoDB: FTS optimize thread exiting.
database_1 | 2021-12-25 15:31:01 0 [Note] InnoDB: Starting shutdown...
database_1 | 2021-12-25 15:31:01 0 [Note] InnoDB: Dumping buffer pool(s) to /var/lib/mysql/ib_buffer_pool
database_1 | 2021-12-25 15:31:01 0 [Note] InnoDB: Buffer pool(s) dump completed at 211225 15:31:01
database_1 | 2021-12-25 15:31:01 0 [Note] InnoDB: Removed temporary tablespace data file: "./ibtmp1"
database_1 | 2021-12-25 15:31:01 0 [Note] InnoDB: Shutdown completed; log sequence number 42628; transaction id 19
database_1 | 2021-12-25 15:31:01 0 [Note] mysqld: Shutdown complete
database_1 |
database_1 | 2021-12-25 15:31:02+00:00 [Note] [Entrypoint]: Temporary server stopped
database_1 |
database_1 | 2021-12-25 15:31:02+00:00 [Note] [Entrypoint]: MariaDB init process done. Ready for start up.
database_1 |
database_1 | 2021-12-25 15:31:02 0 [Note] mysqld (mysqld 10.6.1-MariaDB-1:10.6.1+maria~focal) starting as process 1 ...
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: Compressed tables use zlib 1.2.11
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: Number of pools: 1
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
database_1 | 2021-12-25 15:31:02 0 [Note] mysqld: O_TMPFILE is not supported on /tmp (disabling future attempts)
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: Using Linux native AIO
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: Completed initialization of buffer pool
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: 128 rollback segments are active.
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: Creating shared tablespace for temporary tables
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: Setting file './ibtmp1' size to 12 MB. Physically writing the file full; Please wait ...
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: 10.6.1 started; log sequence number 42628; transaction id 18
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/mysql/ib_buffer_pool
database_1 | 2021-12-25 15:31:02 0 [Note] Plugin 'FEEDBACK' is disabled.
database_1 | 2021-12-25 15:31:02 0 [Warning] You need to use --log-bin to make --expire-logs-days or --binlog-expire-logs-seconds work.
database_1 | 2021-12-25 15:31:02 0 [Note] Server socket created on IP: '0.0.0.0'.
database_1 | 2021-12-25 15:31:02 0 [Note] Server socket created on IP: '::'.
database_1 | 2021-12-25 15:31:02 0 [Warning] 'proxies_priv' entry '@% root@66d18f02ea8a' ignored in --skip-name-resolve mode.
database_1 | 2021-12-25 15:31:02 0 [Note] InnoDB: Buffer pool(s) load completed at 211225 15:31:02
database_1 | 2021-12-25 15:31:02 0 [Note] mysqld: ready for connections.
database_1 | Version: '10.6.1-MariaDB-1:10.6.1+maria~focal' socket: '/run/mysqld/mysqld.sock' port: 3306 mariadb.org binary distribution
It looks to me as if the .env-parameters
are not given to the database-container anymore. All attempts recreating the database-container with docker-compose build
, or removing all images via docker image prune
and docker-compose pull
have been in vain. I have updated my OS from 21.04 to 21.10 two days ago, but I don’t think it causes the issue (just stated it here if it does). Does someone has an idea on how to fix this? Setting the MYSQL_ROOT_PASSWORD
directly in the docker-compose.yml
did not help either. The permission on database_persist are set via sudo chown -R $USER:$USER database_persist/
so that should not be an issue as well.
Thanks (and merry Christmas 🙂 )
Edit: I tried reinstalling docker and updating docker-compose to version 2.2.2 (edited accordingly), but it had no effect. One of the commentors asked if I can connect to the container. Yes, I can, but not as root.
2
Answers
Okay - for some weird reason the output stays the same, but when I try to login the dbroot and the dbuser actually use their passwords specified in the env-files. Plus using anything else will result in a "access denied". So I don't know if the update fixed the issue or if the logoutput just scared me and this is actually the expected behaviour. I will update this if I get any new insights.
The
.env
file can be parsed as a part of thedocker-compose.yaml
. Though I personally never used this the way you do, as you can also pass a file directly into the container. With theenv_file
keyObviously, you then also need to change the variable names in your .env file. And I personally would rename it to a more clear name.