Docker Community Forums

Share and learn in the Docker community.

[MYSQL] --restart always looses volume information

(Romeo Disca) #1


I encountered a problem with the standard mysql container.

docker run -d --restart always -v …:/var/lib/mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root mysql

after rebooting windows the container starts as expected but looses volume specification, so my app cannot access my database.

I need to drop the running container and re-enter the docker run command to get it visible in mysql databases list

Has someone else encountered such a behavior?
Is this only observed for mysql?

(Michael Friis) #2

This is a known limitation:

I recommend not using host-mounted volumes. Use a named volume instead.

(Henriqueferreira) #3

Hello @friism, what do you mean when you say named volumes?
I’m having volume troubles with my docker containers (created via docker-compose).

For instance, my mysql container is described as so:

image: mysql
- "3306:3306"
- ./mysql:/var/lib/mysql
restart: always

When I restart the container all is well, but after some time the volumes are inaccessible.

Thanks :wink: