问题描述
我正在使用Docker for Mac 1.12.1,并有一个docker组合文件启动wordpress和mysql服务撰写文件
版本:'2'
服务:
db:
容器名称:mysql_db
image:mysql:5.7
卷:
- ./.data/db:/var/lib/mysql
重新启动:总是
环境:
MYSQL_ROOT_PASSWORD :wordpress
MYSQL_DATABASE:wordpress
MYSQL_USER:wordpress
MYSQL_PASSWORD:wordpress
wordpress:
container_name:wordpress
depends_on:
- db
image:wordpress:最新
链接:
- db
ports:
- 8000:80
重新启动:总是
环境:
WORDPRESS_DB_HOST:db:3306
WORDPRESS_DB_PASSWORD:wordpress
卷:
- wordpress /:/ var / www / html /
卷:
wordpress:
MacBookAir:wordpress carlwainwright $ docker卷检查wordpress_wordpress
[
{
名称:wordpress_wordpress,
驱动程序:本地,
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 /:没有这样的文件或目录
任何想法?
请请记住,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
总计148
drwxr-xr-x 3根根4096 5月16日13:20 04576d248c19b1210d47e94c8211493428cd3c3aa71dfe3fa0f4214589a6f875
drwxr-xr-x 3根根4096 5月16日13:20 31af0f01492d8f7b832dad75e731b754302e84fbecfa7c654d7de10465bec204
等
I'm using Docker for Mac 1.12.1 and have a docker compose file which starts wordpress and mysql services
Compose file
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:
However after bringing everything up successfully I cannot find where the named volume exists on my 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
Any ideas?
Please keep in mind, Docker for Mac runs a docker engine in a Linux VM, not your Mac OS, so you can't find the volume's mount point in your Mac OS file system. The volume files should existing in that Linux VM's file system.
However, you can login Docker for Mac's VM via screen:
$ screen ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/tty
#user: root
#password: xxxxxx
Then you can view the docker's volumes:
$ 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.
这篇关于Docker命名卷位置Mac的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!