0

I would like to persist some configuration data from a container and am following the tutorial on data volumes.

I'm successfully running the app with:

docker run -it --privileged -v /app/config -p 8083:8083 myapp-ubuntu:2.2.2

Where -v /app/config is the directory inside the container that contains the config that should survive a container restart.

Also the result of running the container creates a volume in /var/lib/docker/volumes.

# ls /var/lib/docker/volumes
5e60d70dc15bcc53aa13cfd84507b5758842c7743d43da2bfa2fc121b2f32479

However, if I kill the container and rerun it no data is persisted and a new volume is created in /var/lib/docker/volumes:

# ls /var/lib/docker/volumes
5e60d70dc15bcc53aa13cfd84507b5758842c7743d43da2bfa2fc121b2f32479  (FIRST RUN)
82de3aa910bc38157a6dc20a516b770bd0264860ae83093d471212f69960d02a  (SECOND RUN)

I would expect that these would be the steps for persisting, am I missing something here?

4

2 回答 2

1

我认为您可以使用命名卷来解决它:

docker run -it --privileged -v some_named_volume:/app/config -p 8083:8083 myapp-ubuntu:2.2.2
于 2016-05-17T15:44:02.150 回答
0

或者你可以使用带有指令 COPY 的 Dockerfile

于 2016-05-17T17:19:17.167 回答