Docker cheat sheet to handle the Docker universe

Before a while I got in touch with the wonderful world of the Docker (see https://www.docker.com) cosmos. I think it is one of the most important virtualisation technology at the moment.

On this page I will just collect useful commands that helped me a lot in my daily work with Docker, Docker-Compose (https://docs.docker.com/compose/) and other stack related tools such AWS Docker registries. Additionally I will continuously collect useful links, that helped me to get along in the wide field of docker.

Useful Docker commands:

  • run an  arbitrary Docker image (available on Dockerhub) and open a shell into the launched machine:
    $> docker run -i -t python:3.5.1 /bin/bash
    or an alpine based one:
    $> docker run -i -t python:3.6.5-alpine3.7 /bin/ash
  • list all running containers
    $> docker ps
  • mount folder into a container to have access to the files in the current folder:
    $> docker run -v $PWD:/path/inside/docker/container -i -t python:3.6.5-alpine3.7 /bin/as
  • or a file (overrides existing targets f.e. if you want to replace a configuration file at runtime that was created during buildtime of the container image)
    $> docker run -v $(pwd)/test/deploy_conf.yml:/app/config/deploy_conf.yml -i -t mina:test /bin/ash
  • list all orphaned volumes (not used by any container anymore):
  • remove a single image:
  • remove all orphaned volumes at once:
  • t.b.c

Useful Docker shortcuts:

I placed these shortcuts inside my .bash_alias file under Linux, so that I have autocomplete / suggests:

Further information about the Docker cosmos:

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.