我的 docker-compose.yml 如下
version: '3.3'
services:
db:
image: mysql:5.7
container_name: mysql-wordpress
volumes:
- db_data:/var/lib/mysql
ports:
- "3300:3306"
restart: always
environment:
MYSQL_ROOT_PASSWORD: root
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
container_name: wordpress
depends_on:
- db
image: wordpress:latest
volumes:
- ./wp-content:/var/www/html/wp-content
- ./uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
ports:
- "80:80"
- "443:443"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_USER: wordpress
WORDPRESS_DB_PASSWORD: wordpress
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
depends_on:
- db
restart: always
ports:
- "8080:80"
environment:
- PMA_ARBITRARY=1
volumes:
db_data:
当我开始docker-compose up -d
wp-content 目录与容器 wp-content 目录内的主机内容不同。
当我这样做时docker inspect WordPress
:
"Mounts": [
{
"Type": "bind",
"Source": "/rootfs/home/rancher/projects/tabletop/uploads.ini",
"Destination": "/usr/local/etc/php/conf.d/uploads.ini",
"Mode": "rw",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "bind",
"Source": "/rootfs/home/rancher/projects/tabletop/wp-content",
"Destination": "/var/www/html/wp-content",
"Mode": "rw",
"RW": true,
"Propagation": "rprivate"
},
{
"Type": "volume",
"Name": "d0a4f5ad342db0db782b41dd676aa0e58a324b5e7db1e56086bca5550a9ffdc3",
"Source": "/var/lib/docker/volumes/d0a4f5ad342db0db782b41dd676aa0e58a324b5e7db1e56086bca5550a9ffdc3/_data",
"Destination": "/var/www/html",
"Driver": "local",
"Mode": "",
"RW": true,
"Propagation": ""
}
看来第三个挂载可能已经覆盖了我的绑定挂载。但我不知道它来自哪里。我怎样才能在它之后挂载我的 wp-content?
更新:这个问题只发生在 rancherOS 、 coreOS 和 linux Mint 上,它工作正常