docker的cp不会recursion复制

我有以下容器:

» 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 。 我想要这些数据的副本,检查主机中的configuration等等:

 » 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 

旧版本无法从卷中docker cp数据。 更新到1.4.0或更新,它的工作原理!

这是一个古老的问题,但Docker 1.12又是相关的 – 文件复制正确,但没有复制到已经在容器上的卷上创build的目录中。

在这里创build一个问题:

https://github.com/docker/docker/issues/25755