I've already tried the solution in this stackoverflow thread. It did not work for me, as shown below.
Here's my docker-compose.yml
file:
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
Here's the result of 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.
Instead of type: none
, I have also tried type: volume
and type: bind
, but I got the same error.
The directory clearly exists:
$ ls -al /usr/local/opt/mysql/
...
drwxr-xr-x 2 cameronhudson staff 64 Jun 10 10:32 mywebsite.com
...