[MYSQL] --restart always looses volume information

Hi,

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?

This is a known limitation: https://github.com/docker/for-win/issues/584#issuecomment-286792858

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

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:

mysql:
image: mysql
ports:
- "3306:3306"
volumes:
- ./mysql:/var/lib/mysql
environment:
- MYSQL_ROOT_PASSWORD=----
restart: always

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

Thanks :wink: