我正在努力将我的 Docker Compoe 项目与 Wordpress 和 Mysql 迁移/移动到新主机。
我docker-compoye.yaml
的如下:
version: '3.1'
services:
wordpress:
image: wordpress
restart: always
ports:
- 8099:80
environment:
WORDPRESS_DB_HOST: db
WORDPRESS_DB_USER: root
WORDPRESS_DB_PASSWORD: 'ahw5ai8gu9waewiuNgaithev7xie0jah'
WORDPRESS_DB_NAME: wordpress
WORDPRESS_DEBUG: 1
depends_on:
- db
volumes:
- .wordpress/plugins:/var/www/html/wp-content/plugins
- .wordpress/themes:/var/www/html/wp-content/themes
- .wordpress/uploads:/var/www/html/wp-content/uploads
- ./wordpress.ini:/usr/local/etc/php/conf.d/wordpress.ini
db:
image: mysql:5.7
restart: always
ports:
- 3306:3306
environment:
MYSQL_DATABASE: exampledb
MYSQL_USER: exampleuser
MYSQL_PASSWORD: examplepass
MYSQL_ROOT_PASSWORD: ahw5ai8gu9waewiuNgaithev7xie0jah
volumes:
- .db:/var/lib/mysql
目录结构如下:
drwxrwxr-x 8 999 mbecker 4,0K Mär 5 09:36 .db
-rwxrwxr-x 1 mbecker mbecker 2,5K Mär 2 16:39 docker-compose.yaml
drwxrwxrwx 6 mbecker mbecker 4,0K Apr 11 2021 .wordpress
我已经完成了以下迁移策略,将完整的目录/文件复制到新主机:
- 将完整目录(和子目录)rsync 到新的 hist
- 创建本地目录 recursive 的 .tar 文件,移至新主机,然后解压
但是,卷/目录路径等中的文件权限.wordpress/plugins/
从 更改www-data
为mbecker
。
在新主机上启动docker compose项目会导致以下Wordpress错误:
Notice: Function WP_User_Query::query was called incorrectly. User queries should not be run before the plugins_loaded hook. Please see Debugging in WordPress for more information. (This message was added in version 6.1.1.) in /var/www/html/wp-includes/functions.php on line 5835
** 通过导入脚本正确导入数据库数据 ** DNS 名称指向新 IP,并且 Nginx 反向代理指令相同
有什么想法可以了解如何以正确的文件权限将数据从一台主机移动至另一台主机?
答案1
一般来说,要修复权限问题,执行“sudo chown -R www-data:www-data folder”应该有效。就我而言,我忘记指定图像标签了。Docker 会自动拉取带有“latest”标签的图像;docker compose 项目已经运行了好几年,“latest”图像是 2 年前的图像。我已将正确的图像标签添加到新迁移的 docker compose 项目中,并且它正在运行。