U
U
user.2019-12-09 22:24:52
Docker
user., 2019-12-09 22:24:52

Running a docker container with data persistence?

Good evening,
You need to run a docker container with the ability to save data after reboot/shutdown/crash.
Having studied this question a little, I found two options.
1. Periodically commit the container (not very willing to do this)
2. Each time you start, mount the volume into which the specified directories from the container will be automatically replicated.
An example of what I'm trying:

docker run  --name some_name -v /media/mount_dir:/dockerdir -itd docker.io/centos /bin/bash

Result: mount_dir is always empty.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mureevms, 2019-12-10
@mureevms

Are you waiting for something to show up? Create a file there manually and make sure that it is present on the host system:

docker exec some_name touch /dockerdir/test
ls /media/mount_dir/

And then create on the host system and check in the container:
touch /media/mount_dir/test222
docker exec some_name ls /dockerdir

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question