search by tags

for the user

adventures into the land of the command line

docker cheatsheet

Docker daemon log file locations

Ubuntu (old using upstart ) - /var/log/upstart/docker.log
Ubuntu (new using systemd ) - journalctl -u docker.service
Boot2Docker - /var/log/docker.log
Debian GNU/Linux - /var/log/daemon.log
CentOS - /var/log/daemon.log | grep docker
CoreOS - journalctl -u docker.service
Fedora - journalctl -u docker.service
Red Hat Enterprise Linux Server - /var/log/messages | grep docker
OpenSuSE - journalctl -u docker.service
OSX - ~/Library/Containers/com.docker.docker/Data/com.docker.driver.amd64-linux/log/docker.log

Run a container with a loop so you can enter it

$ docker run -d --name angular_app angular_app /bin/bash -c "while true; do echo blah; sleep 1; done"
$ docker exec -it angular_app /bin/bash

Access files built on a container that stops after it finishes building

$ docker run -i --name something -v /dir:/dir something /bin/bash -c "npm i"
$ docker commit something something-built
$ docker run -i --name something-built -v /dir:/dir something-built /bin/bash -c "npm t"

Remove all exited containers

$ docker container prune

Remove all old images

$ docker image prune -af

Check whether a container is running or not

$ docker inspect --format {{.State.Running}} something_container

Check container stats

$ docker stats something_container --format {{.MemPerc}}{{.CPUPerc}} --no-stream

Save an image as a tarball (in case you have it locally on one computer, and you can’t pull it on another computer for some reason) and transfer it to another computer.

1st computer:

$ docker save -o /tmp/kubelet.tgz kubelet
$ scp /tmp/kubelet.tgz

2nd computer:

$ docker load -i /tmp/kubelet.tgz