> ## Content Index
> Fetch the complete content index at: https://til.codes/llms.txt
> Use this file to discover other available public pages before exploring further.

# Copy file from host machine to docker container
- URL: https://til.codes/copy-file-from-host-machine-to-docker-container/
- Published: 2016-07-13T12:26:00.000Z
- Updated: 2016-12-16T06:14:05.000Z
- Author: Manu Ajith
- Tags: docker, til, shell, #Import 2024-07-13 21:01

The `docker cp` utility copies the contents of `SRC_PATH` to the `DEST_PATH`. You can copy from the container’s file system to the local machine or the reverse, from the local filesystem to the container. If `-` is specified for either the `SRC_PATH` or `DEST_PATH`, you can also stream a tar archive from STDIN or to STDOUT. The CONTAINER can be a running or stopped container. The SRC\_PATH or DEST\_PATH can be a file or directory.

```
Usage: docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH | -
       docker cp [OPTIONS] SRC_PATH | - CONTAINER:DEST_PATH

Copy files/folders between a container and the local filesystem

  -L, --follow-link          Always follow symbol link in SRC_PATH
  --help                     Print usage

```

For example:

```
docker cp foo.txt mycontainer:/foo.txt
docker cp mycontainer:/foo.txt foo.txt

```

Reference: [Docker CLI docs for cp](https://docs.docker.com/engine/reference/commandline/cp/?ref=til.codes)