Docker Cheat Sheet/Copy files from a container

Copy files from container to host.

Section: Containers

Copy files from a container

bash
bash
docker cp web:/var/log/nginx/access.log ./access.log
Explanation

Good for extracting logs and generated artifacts.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Containers
Copy files into a container
Copy files from host to container.
OpenIn sheetbashsame section
Run a container
Create and start a new container.
OpenIn sheetbashsame section
Run detached
Run a container in the background.
OpenIn sheetbashsame section
Run interactively
Run an interactive shell inside a new container.
OpenIn sheetbashsame section
Publish a port
Publish a container port to the host.
OpenIn sheetbashsame section
Set environment variables
Pass environment variables into the container.
OpenIn sheetbashsame section