我正在使用Docker for Mac 1.12.1并且有一个docker compose文件启动wordpress和mysql服务
撰写文件
version: '2'
services:
db:
container_name: mysql_db
image: mysql:5.7
volumes:
- "./.data/db:/var/lib/mysql"
restart: always
environment:
MYSQL_ROOT_PASSWORD: wordpress
MYSQL_DATABASE: wordpress
MYSQL_USER: wordpress
MYSQL_PASSWORD: wordpress
wordpress:
container_name: wordpress
depends_on:
- db
image: wordpress:latest
links:
- db
ports:
- "8000:80"
restart: always
environment:
WORDPRESS_DB_HOST: db:3306
WORDPRESS_DB_PASSWORD: wordpress
volumes:
- wordpress/:/var/www/html/
volumes:
wordpress:
然而,在成功完成所有操作后,我无法找到Mac上存在指定卷的位置。
MacBookAir:wordpress carlwainwright$ docker volume inspect wordpress_wordpress
[
{
"Name": "wordpress_wordpress",
"Driver": "local",
"Mountpoint": "/var/lib/docker/volumes/wordpress_wordpress/_data",
"Labels": null,
"Scope": "local"
}
]
MacBookAir:wordpress carlwainwright$ ls -l /var/lib/docker/volumes/wordpress_wordpress/_data/
ls: /var/lib/docker/volumes/wordpress_wordpress/_data/: No such file or directory
有什么想法吗?
答案 0 :(得分:13)
请记住,Docker for Mac在Linux VM中运行docker引擎,而不是Mac OS,因此您无法在Mac OS文件系统中找到卷的挂载点。卷文件应该存在于该Linux VM的文件系统中。
但是,您可以通过屏幕登录Docker for Mac的VM:
$ screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
#user: root
#password: xxxxxx
然后您可以查看泊坞窗的卷:
$ ls -ltrh /var/lib/docker/volumes
total 148
drwxr-xr-x 3 root root 4096 May 16 13:20 04576d248c19b1210d47e94c8211493428cd3c3aa71dfe3fa0f4214589a6f875
drwxr-xr-x 3 root root 4096 May 16 13:20 31af0f01492d8f7b832dad75e731b754302e84fbecfa7c654d7de10465bec204
etc.