我现在有docker-compose
一段时间遇到问题,无法弄清楚那里发生了什么。给出了以下场景 - 之前作业过但停止在新项目上作业,现在在我建立的每个新堆栈上作业:
$ docker --version
Docker version 20.10.12, build e91ed57
$ docker-compose --version
Docker Compose version v2.2.2
OS: Pop!_OS 21.10 (NVIDIA)
档案结构:
/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
这是缩短的docker-compose.yml-file
(缩短的,因为它只影响数据库...... nginx 和 php-container 作业正常):
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"
和 .env 档案:
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
现在我的问题 - 每当我尝试设定场景中给出的环境并运行时docker-compose build
,docker-compose up
我都会得到以下输出:
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.
uj5u.com热心网友回复:
该.env
档案可以被决议为docker-compose.yaml
. 尽管我个人从未像您那样使用过这种方式,因为您也可以将档案直接传递到容器中。用env_file
钥匙
version: '3'
services:
database:
env_file: .env
image: mariadb:10.6.1
ports:
- "${DB_EXPOSE_PORT}:3306"
volumes:
- "./database_persist:/var/lib/mysqldata"
显然,您还需要更改 .env 档案中的变量名称。我个人会将其重命名为更清晰的名称。
uj5u.com热心网友回复:
好的 - 由于某种奇怪的原因,输出保持不变,但是当我尝试登录 dbroot 时,dbuser 实际上使用了他们在 env 档案中指定的密码。加上使用其他任何东西都会导致“访问被拒绝”。所以我不知道更新是否解决了问题,或者日志输出是否只是让我害怕,这实际上是预期的行为。如果我有任何新的见解,我会更新这个。
0 评论