14

I'm trying to start a mysql container with a host directory mounted. I'm running a single-node swarm in Docker for AWS. But I can't mount a directory...

This is the section of the docker-compose file I'm using:

mysql:
    image: mysql-custom
    volumes:
        - /mysql:/var/lib/mysql
    ports:
        - "3307:3306"

And this is the launch command I'm trying:

docker stack deploy --compose-file docker-compose.yml stack12

When I launch however, docker swarm rejects the image, saying "invalid mount config for type \"bind\": bind source path does not exist". However, /mysql is a valid directory, I can cd to it and everything, so why is docker saying it does not exist?

Scott Shorkey
  • 325
  • 4
  • 10

2 Answers2

0

According to what you are trying, mysql needs to be in root directory. You can try this

mysql:
    image: mysql-custom
    volumes:
        - ./mysql:/var/lib/mysql
    ports:
        - "3307:3306"

Notice the . before mysql. And directory structure for this can be:

.
|__docker-compose.yml
|__mysql
   |__(Your content)
   |__(some more files)
Ayushya
  • 9,599
  • 6
  • 41
  • 57
0

I experienced the same issue due to permissions. I recommend you make a test where you grant 777 to /mysql to see if it works -> then tweak the permissions to match your security requirements

Pablo Henkowski
  • 197
  • 1
  • 6