github.com/tsuna/docker@v1.7.0-rc3/man/docker-cp.1.md (about)

     1  % DOCKER(1) Docker User Manuals
     2  % Docker Community
     3  % JUNE 2014
     4  # NAME
     5  docker-cp - Copy files or folders from a container's PATH to a HOSTDIR
     6  or to STDOUT.
     7  
     8  # SYNOPSIS
     9  **docker cp**
    10  [**--help**]
    11  CONTAINER:PATH HOSTDIR|-
    12  
    13  # DESCRIPTION
    14  
    15  Copy files or folders from a `CONTAINER:PATH` to the `HOSTDIR` or to `STDOUT`. 
    16  The `CONTAINER:PATH` is relative to the root of the container's filesystem. You
    17  can copy from either a running or stopped container. 
    18  
    19  The `PATH` can be a file or directory. The `docker cp` command assumes all
    20  `PATH` values start at the `/` (root) directory. This means supplying the
    21  initial forward slash is optional; The command sees
    22  `compassionate_darwin:/tmp/foo/myfile.txt` and
    23  `compassionate_darwin:tmp/foo/myfile.txt` as identical.
    24  
    25  The `HOSTDIR` refers to a directory on the host. If you do not specify an
    26  absolute path for your `HOSTDIR` value, Docker creates the directory relative to
    27  where you run the `docker cp` command. For example, suppose you want to copy the
    28  `/tmp/foo` directory from a container to the `/tmp` directory on your host. If
    29  you run `docker cp` in your `~` (home) directory on the host:
    30  
    31  		$ docker cp compassionate_darwin:tmp/foo /tmp
    32  
    33  Docker creates a `/tmp/foo` directory on your host. Alternatively, you can omit
    34  the leading slash in the command. If you execute this command from your home directory:
    35  
    36  		$ docker cp compassionate_darwin:tmp/foo tmp
    37  
    38  Docker creates a `~/tmp/foo` subdirectory.  
    39  
    40  When copying files to an existing `HOSTDIR`, the `cp` command adds the new files to
    41  the directory. For example, this command:
    42  
    43  		$ docker cp sharp_ptolemy:/tmp/foo/myfile.txt /tmp
    44  
    45  Creates a `/tmp/foo` directory on the host containing the `myfile.txt` file. If
    46  you repeat the command but change the filename:
    47  
    48  		$ docker cp sharp_ptolemy:/tmp/foo/secondfile.txt /tmp
    49  
    50  Your host's `/tmp/foo` directory will contain both files:
    51  
    52  		$ ls /tmp/foo
    53  		myfile.txt secondfile.txt
    54  		
    55  Finally, use '-' to write the data as a `tar` file to STDOUT.
    56  
    57  # OPTIONS
    58  **--help**
    59    Print usage statement
    60  
    61  # EXAMPLES
    62  An important shell script file, created in a bash shell, is copied from
    63  the exited container to the current dir on the host:
    64  
    65      # docker cp c071f3c3ee81:setup.sh .
    66  
    67  # HISTORY
    68  April 2014, Originally compiled by William Henry (whenry at redhat dot com)
    69  based on docker.com source material and internal work.
    70  June 2014, updated by Sven Dowideit <SvenDowideit@home.org.au>