I use Mysql docker image to run container for DB. To start it I use docker compose with the following configuration
mysql:
image: mysql
restart: always
environment:
...
...
ports:
- '3306:3306'
expose:
- '3306'
volumes:
- app_data:/var/lib/mysql
It works just fine locally. However when I deploy it on remote server I get data loss.
I run the container on my remote server using docker compose with remote context
docker-compose –context my_remote_context up
Ok! It does not copy the volume data.
I make backup of all the volume data and then copyrestore them on remote server.
There are several ways to restore but they all come to coping the volume data into:
/var/lib/docker/volumes/<my_volume_name>/_data
on the remote server.
Then everything is working fine during several hours.
But then I just notice that my volume data is removed on the remote server. My db is removed.
The volume comes to some default state which is initially set up when I first started my mysql container. It looks as if everything was rolled back
Could you please advise why it could happen?
The contaiter has not been stopped and working but the volume data is lost. Something triggers such behavior.
Zauberer is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.