Sometimes we have Docker containers that just won’t run, maybe they run briefly and then unexpectedly quit. If you don’t have access to the running container, and the logs provided by
docker logs <container id> aren’t very helpful, try this trick.
Let’s say our container has a configuration file that might be the cause of our problem. The Docker CLI provides a way to copy files into and out of stopped containers. The
cp command makes it easy to copy any file from the stopped Docker container back to your host machine for closer inspection.
What it looks like:
docker cp my_container:/path/to/config.conf .
Review file, scratch head, make updates, upload new version to container
docker cp config.conf my_container:/path/to/config.conf