Docker Community Forums

Share and learn in the Docker community.

Copy/migrate database from running container

I want to copy a database from a running container to my host machine:

file /var/lib/grafana/grafana.db
/var/lib/grafana/grafana.db: SQLite 3.x database, last written using SQLite version 3029000

The thing is when I try to copy the file

docker cp -a <CONAINER_ID>:/var/lib/grafana/grafana.db .

I have the following issue:

file grafana.db
grafana.db: regular file, no read permission

Any idea why ?

Also that particular dir is mounted as a volume

docker inspect -f ‘{{ .Mounts }}’
[{bind <LOCAL_MACHINE_PATH>/new_grafana /var/lib/grafana rw true rprivate}]

Hi there.

Am I understanding you correctly that you have this file mounted on your host system?
Cant you just copy it from your host system instead?

Can you run this to provide more info:

docker exec -ti <CONAINER_ID> ls -la /var/lib/grafana/grafana.db