我已经尝试了这个stackoverflow线程中的解决方案。但是对我来说没有起作用,如下所示。
这是我的docker-compose.yml
文件:
version: "3.7"
services:
db:
image: mysql
volumes:
- data:/var/lib/mysql
volumes:
data:
driver_opts:
type: none
device: /usr/local/opt/mysql/mywebsite.com
o: bind
这是
docker-compose up
的结果:$ docker-compose up
Creating volume "mycontainer_data" with default driver
Recreating 45bc03b2c674_mycontainer_db_1 ... error
ERROR: for 45bc03b2c674_mycontainer_db_1 Cannot create container for service db: error while mounting volume with options: type='none' device='/usr/local/opt/mysql/mywebsite.com' o='bind': no such file or directory
ERROR: for db Cannot create container for service db: error while mounting volume with options: type='none' device='/usr/local/opt/mysql/mywebsite.com' o='bind': no such file or directory
ERROR: Encountered errors while bringing up the project.
我曾尝试使用type: none
以外的type: volume
和type: bind
,但是我遇到了同样的错误。
该目录显然存在:
$ ls -al /usr/local/opt/mysql/
...
drwxr-xr-x 2 cameronhudson staff 64 Jun 10 10:32 mywebsite.com
...