
If you have files in your docker container that you want to get into your host/local device, you can achieve it using the docker cp command.
Example:Inside the docker container I have a file 20220901.log under the root directory, I want to get it to my host system,.
# pwd
/root
# ls
20220901.log
Copy file from Docker Container
% docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
1d2b384f31de alpine "/bin/sh" 6 minutes ago Exited (0) 6 minutes ago intelligent_noether
% docker cp 1d2b384f31de:/root/20220901.log
Note: You might get operation not permitted if you try to copy the file to the host directory where you do not have permission to write.
Also, if a path or file does not exist on the docker container you will get an error: No such container:path: or if the host path is invalid: invalid output path: directory does not exist
-
Facing issues? Have Questions? Post them here! I am happy to answer!
More Posts related to Docker,
- Install Docker on Mac using brew cask
- How to know the Docker Sandbox ID of a Container Network?
- How to Rename Docker Image with none TAG and REPOSITORY?
- How to know list of images available on your device
- Docker Alpine Linux and Apache2 Example
- Install Bash on Alpine Linux - Docker
- Docker Run Command Examples - Part 1
- Install the minimal Linux on Docker (only 5 mb Alpine Linux)
- [fix] docker: Error response from daemon: dial unix docker.raw.sock: connect: no such file or directory.
- Install RabbitMQ on Docker
- How to know docker Engine details
- [Fix] Docker Error response from daemon: manifest for :latest not found: manifest unknown
- How to stop and start a docker container
- How to create volume in Docker using Command
- How to know the Docker Engine Version
- [docker] Error response from daemon: No such container
- Install Docker for Mac using Home-brew Cask
- Docker - Incompatible CPU detected - M1/M2 Mac (macOS Sonoma)
- [fix] Docker Desktop App not starting on Mac (macOS)
- Unable to find image docker latest locally
- How to Stop/Cancel/kill docker image pull
- List of what's new in Docker 4.23
- [Docker M1/M2 Mac] qemu-x86_64: Could not open /lib64/ld-linux-x86-64.so.2: No such file or directory AWS CLI
- Install Docker Desktop on M1/M2 Apple Silicon ARM Chip Mac
- Docker - Running in Resource Saver mode
More Posts:
- Fix: UnsupportedClassVersionError: Unsupported major.minor version 63.0 - Java
- Fix: Error: error:0308010C:digital envelope routines::unsupported NodeJs/Vue/React - JavaScript
- Which Python version is bundled with macOS Sonoma 14 by default - MacOS
- Reading JSON file in Python with Examples - Python
- AlertDialog with image using ImageView Example - Android
- Chrome : When Adobe flash player has finished updating, reload this page to active it - Chrome
- Python: Pandas Merge With Examples - Python
- How to rename a directory using Command Line Terminal - Linux