Answer the question
In order to leave comments, you need to log in
How to deploy a copy of a stateful container?
There is a docker container with a database running on it.
Data has been entered into the database.
How to wrap the current container and run a copy of it side by side so that the original state (data in the database) is preserved.
Answer the question
In order to leave comments, you need to log in
In a good way, it is better to mount a volume with data in a docker container: keep the data separate from the engine.
docker run --name some-mysql -v /my/own/datadir:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
### или создать дата-volume и его приделать к контейнеру
docker volume create data_volume
docker run --name some-mysql -v data_volume:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:tag
### так после выключения контейнера данные не пропадут, останутся в этом data_volume,
### который можно скопировать, подключить к другим контейнерам
mysqldump
or whatever database you have. Backups, in any case, must be done. Raise a copy of the container, import data from the dump into it. For examples of commands for mysql in docker, see the Creating database dumps section below :### Creating database dumps
docker exec some-mysql sh -c 'exec mysqldump --all-databases -uroot -p"$MYSQL_ROOT_PASSWORD"' > /some/path/on/your/host/all-databases.sql
### Restoring data from dump files
docker exec -i some-mysql sh -c 'exec mysql -uroot -p"$MYSQL_ROOT_PASSWORD"' < /some/path/on/your/host/all-databases.sql
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question