我已按照 docker 文档中的官方说明成功设置了 WordPress。我正在运行 Windows,但似乎无法弄清楚我在哪里编辑 WordPress 文件,例如wp-content
so on so fourth。这是我docker-compose.yml
用来设置容器的文件。提前谢谢。这与设置有关吗volumes
?我C
与 docker 共享了我的驱动器。
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "8080:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
db_data: {}
编辑:我希望将我的 WordPress 文件放在我设置容器的同一目录中C:/Users/andersk/sites/wordpress
。
答案1
这为我解决了这个问题,添加了一个指向 C 盘文件夹的卷线
volumes:
- C:/Users/andersk/sites/wordpress-site:/var/www/html
请参阅上文以了解添加的行
version: '3.3'
services:
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: somewordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
depends_on:
- db
image: wordpress:latest
ports:
- "3000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
volumes:
- C:/Users/andersk/sites/wordpress-site:/var/www/html // This fixed it
volumes:
db_data: {}