How to Extract Files from a Docker Image
I've been debugging my Docker images recently and checking whether they build correctly. I wanted to find a way to see the structure and files in my local system. It ended up being super simple. The only thing you need to do is:
- build or pull an image,
- run a container,
- and then extract the files from the container to get a complete copy of the system.
Here's how to do it:
# Run your Docker container
docker run --rm -p 3000:3000 webapp:latest
# List running containers and copy the appropriate container ID
docker ps
# Use your container ID here (don't remove `:.` by accident - it's part of the command)
docker cp containerId:. output-location
Published on September 24, 2024 • 1 min read