我有以下容器:
» sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
753f4d01ae32 postgres:9 /usr/src/postgres/do 9 minutes ago Up 9 minutes 5432/tcp postgres
edfbfb3b0837 tutum/couchdb:latest /run.sh 18 minutes ago Up 18 minutes 0.0.0.0:5985->5984/tcp couchdb2
4aa61e51d86f tutum/couchdb:latest /run.sh 18 minutes ago Up 18 minutes 0.0.0.0:5984->5984/tcp couchdb
我正在使用postgres容器:
CID=753f4d01ae32
PID=$(sudo docker inspect --format {{.State.Pid}} $CID)
echo $PID
13949
» sudo nsenter --target $PID --mount --uts --ipc --net --pid /bin/bash
root@753f4d01ae32:/# ls -l /var/lib/postgresql/data/
total 100
-rw------- 1 postgres postgres 4 Aug 1 05:30 PG_VERSION
drwx------ 5 postgres postgres 4096 Aug 1 05:30 base
drwx------ 2 postgres postgres 4096 Aug 1 05:30 global
drwx------ 2 postgres postgres 4096 Aug 1 05:30 pg_clog
-rw------- 1 postgres postgres 4506 Aug 1 05:30 pg_hba.conf
-rw------- 1 postgres postgres 1636 Aug 1 05:30 pg_ident.conf
drwx------ 4 postgres postgres 4096 Aug 1 05:30 pg_multixact
drwx------ 2 postgres postgres 4096 Aug 1 05:30 pg_notify
drwx------ 2 postgres postgres 4096 Aug 1 05:30 pg_serial
drwx------ 2 postgres postgres 4096 Aug 1 05:30 pg_snapshots
drwx------ 2 postgres postgres 4096 Aug 1 05:30 pg_stat
drwx------ 2 postgres postgres 4096 Aug 1 05:41 pg_stat_tmp
drwx------ 2 postgres postgres 4096 Aug 1 05:30 pg_subtrans
drwx------ 2 postgres postgres 4096 Aug 1 05:30 pg_tblspc
drwx------ 2 postgres postgres 4096 Aug 1 05:30 pg_twophase
drwx------ 3 postgres postgres 4096 Aug 1 05:30 pg_xlog
-rw------- 1 postgres postgres 20494 Aug 1 05:30 postgresql.conf
-rw------- 1 postgres postgres 30 Aug 1 05:30 postmaster.opts
-rw------- 1 postgres postgres 70 Aug 1 05:30 postmaster.pid
很酷,所以我有/var/lib/postgresql/data
中的数据。我想要一份该数据的副本,以检查主机中的配置等等:
» sudo docker cp $CID:/var/lib/postgresql/data .
» tree data/
data/
0 directories, 0 files
所以,docker cp
没有复制任何东西!为什么呢?
我正在使用:
» docker --version
Docker version 0.9.1, build 3600720
答案 0 :(得分:1)
旧版本无法docker cp
来自Volume的数据。更新到1.4.0或更高版本,它可以工作!