Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?

Travis

Docker

Docker Hub

Using Docker

  • Image names: user/name:tag (user is missing for the official Docker images, tag is usually the version)

Base Images

  • docker run -it opensuse bash (equals to opensuse:latest, which is 42.2, use opensuse:tumbleweed for the TW)
  • docker run -it fedora:25 bash
  • docker run -it ubuntu:14.04 bash
  • docker run -it alpine sh minimal busybox system (~4MB)

Applications

  • docker run -it -p 8080:80 nginx open http://localhost:8080
  • docker run -it -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123 mysql connect via mysql -h 127.0.0.1 -u root -p or shutdown via mysqladmin -h 127.0.0.1 -u root -p shutdown

YaST Images

Image Rebuild

Travis Integration

The Snapper Trick

Snapper is built for different 5 distributions in Travis.

Basic Docker Commands

  • Installing Docker: zypper in docker && systemctl start docker or see https://docs.docker.com/engine/installation/linux/suse/ if you want the latest version from a 3rd party repo
  • All following commands require root
  • docker build -t <tag> . builds an image (the last arg is a dir with Dockerfile)
    • The build steps are cached
  • docker run -it <image> <command> start a new container (-i interactive, -t use a TTY)
  • see man docker-run
  • docker images prints available images
  • docker ps prints containers (-a also stopped)

Docker Tips&Tricks

  • docker commit save result of a stopped container
  • docker run --rm deletes the result
  • CTRL-p CTRL-q detach (in TTY mode)
  • docker attach <container> attach
  • docker top <container>
  • docker stats <container>
  • docker rm <container> remove container
  • docker rmi <image> remove image
  • docker images -q --filter "dangling=true" | xargs docker rmi remove unused images
  • docker rm `docker ps -a -q` removes all containers
  • docker rmi `docker images -q` removes all images

Documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment