wordpress - Bitnami的Wordpress Docker设置的持久性

标签 wordpress docker docker-compose mariadb bitnami

我正在尝试使用以下文档设置Wordpress:

https://github.com/bitnami/bitnami-docker-wordpress#mount-host-directories-as-data-volumes-with-docker-compose

我的卷主机目录在docker-compose文件中如下所示:

volumes:
  - './mariadb_data:/bitnami'
...
volumes:
  - './wordpress_data:/bitnami'

运行docker-compose up时,发生以下错误:
mariadb_1    | INFO  ==> Starting mysqld_safe...
mariadb_1    | Could not open required defaults file: /opt/bitnami/mariadb/conf/my.cnf
mariadb_1    | Fatal error in defaults handling. Program aborted
mariadb_1    | WARNING: Defaults file '/opt/bitnami/mariadb/conf/my.cnf' not found!
mariadb_1    | Could not open required defaults file: /opt/bitnami/mariadb/conf/my.cnf
mariadb_1    | Fatal error in defaults handling. Program aborted
mariadb_1    | WARNING: Defaults file '/opt/bitnami/mariadb/conf/my.cnf' not found!
mariadb_1    | 171105 05:15:41 mysqld_safe Logging to '/opt/bitnami/mariadb/data/200101d1b330.err'.
mariadb_1    | 171105 05:15:41 mysqld_safe Starting mysqld daemon with databases from /opt/bitnami/mariadb/data
mariadb_1    | /opt/bitnami/mariadb/bin/mysqld_safe_helper: Can't create/write to file '/opt/bitnami/mariadb/data/200101d1b330.err' (Errcode: 2 "No such file or directory")
myproject_mariadb_1 exited with code 1

但是,如果我将docker-compose文件更改为使用非主机目录:
volumes:
  - 'mariadb_data:/bitnami'
...
volumes:
  - 'wordpress_data:/bitnami'

... docker-compose up有效。

如果我随后停止docker,然后还原我的docker-compose文件以再次使用主机目录,则docker-compose up现在可以正常工作,并且主机目录已正确填充。

这是解决我的问题的一种方法,但是我想知道为什么,以及是否有一种方法可以在没有这种解决方法的情况下使工作正常。

最佳答案

检查 bitnami/bitnami-docker-mariadb issue 123是否与您的情况相关:

It seems that docker-compose up did not create a container from scratch (with a clean filesystem), but instead used one preexisting. I deduce this from the beginning sequence:


Starting mariadb_mariadb_1
Attaching to mariadb_mariadb_1
...

It seems to me that this container, in its previous execution, was started with an attached volume at /bitnami/mariadb. After that, the container was stopped, such volume detached, and then the container was restarted. It didn't configure anything and just tried to run the mysql server binary. Since we perform symbolic links from /opt/bitnami/mariadb pointing to /bitnami/mariadb (my.cnf file included), that file went missing and the binaries crashed at start time.

Could you please try using the docker-compose file we provide in this repo? If you only modify it for adding environment variables you shouldn't run into these kind of issues.

As a workaround, just run the following:


docker-compose down -v
docker-compose up

It will remove the the MariaDB container, along with any volume associated, and start from scratch. Bear in mind that you will lose any state you set in the container.

关于wordpress - Bitnami的Wordpress Docker设置的持久性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47118477/

相关文章:

php - 特殊类别帖子的不同循环

linux - tensorflow docker gpu 图像未检测到我的 GPU

docker - Docker Compose 适合生产环境吗?

php - 隐藏 WooCommerce 感谢页面订单详细信息

php - 直接访问 wordpress 表有危险吗?

css - float div 不会扩展以适应动态内容

amazon-web-services - 运行时找不到 Codebuild aws 命令?

docker - docker compose:使用网桥时不分配主机名

docker - 如何防止每次部署到 bitbucket 时 docker 都编译库?是否有 Bitbucket 管道缓存?

docker - 如何从 jenkins docker 容器在主机上运行 shell 脚本?