Difference between revisions of "Docker goodies"
Jump to navigation
Jump to search
(Created page with "=== Remove untagged docker images === http://jimhoskins.com/2013/07/27/remove-untagged-docker-images.html <source lang='bash'> docker rmi $(docker images | grep "^<none>" | aw...") |
|||
(7 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | === Copy a file from a container to the host system === | ||
+ | * http://stackoverflow.com/a/22050116/1497139 | ||
+ | <source lang='bash'> | ||
+ | docker cp <containerId>:/file/path/within/container /host/path/target | ||
+ | </source> | ||
+ | |||
+ | === Attach to a running container === | ||
+ | * http://askubuntu.com/questions/505506/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode | ||
+ | * http://askubuntu.com/a/507009/129227 | ||
+ | <source lang='bash'> | ||
+ | docker exec -it $containername /bin/bash | ||
+ | </source> | ||
+ | |||
=== Remove untagged docker images === | === Remove untagged docker images === | ||
− | http:// | + | http://stackoverflow.com/a/28377696/1497139 |
+ | <source lang='bash'> | ||
+ | docker rmi -f $(docker images -f "dangling=true" -q) | ||
+ | </source> | ||
+ | === get logs of a container === | ||
+ | <source lang='bash'> | ||
+ | docker logs $containername | ||
+ | </source> | ||
+ | === remove old unused docker containers === | ||
+ | * http://stackoverflow.com/a/17237701/1497139 | ||
<source lang='bash'> | <source lang='bash'> | ||
− | docker | + | docker ps -a | grep 'weeks ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm |
</source> | </source> | ||
+ | |||
+ | |||
+ | === Support for build env variables === | ||
+ | Upcoming feature in 1.9? | ||
+ | * https://github.com/docker/docker/issues/6822 |
Latest revision as of 08:15, 16 November 2015
Copy a file from a container to the host system
docker cp <containerId>:/file/path/within/container /host/path/target
Attach to a running container
- http://askubuntu.com/questions/505506/how-to-get-bash-or-ssh-into-a-running-container-in-background-mode
- http://askubuntu.com/a/507009/129227
docker exec -it $containername /bin/bash
Remove untagged docker images
http://stackoverflow.com/a/28377696/1497139
docker rmi -f $(docker images -f "dangling=true" -q)
get logs of a container
docker logs $containername
remove old unused docker containers
docker ps -a | grep 'weeks ago' | awk '{print $1}' | xargs --no-run-if-empty docker rm
Support for build env variables
Upcoming feature in 1.9?