Skip to content

Instantly share code, notes, and snippets.

@aleclarson
Last active September 16, 2017 02:39
Show Gist options
  • Save aleclarson/065da116673657b246b7f70fdea56730 to your computer and use it in GitHub Desktop.
Save aleclarson/065da116673657b246b7f70fdea56730 to your computer and use it in GitHub Desktop.
Docker tips & tricks

Explore filesystem of a container

docker exec -t -i b5ae54373681 /bin/bash

Copy container to host directory

docker cp b5ae54373681:app ~/app-b5ae54373681

Copy host directory to localhost

scp -r [email protected]:/home/vagrant/app-b5ae54373681 ~/app-b5ae54373681

Inspect container that failed to build

# Get the CID of the failed build.
docker ps -a

# Get the SHA of the failed layer.
docker commit b5ae54373681

# Explore the container with bash.
docker run -it 1f14a0f18a46 /bin/bash

Remove dangling images

docker rmi $(docker images -f "dangling=true" -q)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment