gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 20:10:11 28 4
gpt4 key购买 nike

我正在尝试使用以下文档设置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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com