Skip to content

Instantly share code, notes, and snippets.

@thejmazz
Last active November 2, 2016 14:17
Show Gist options
  • Save thejmazz/6735254e107432cb0c8716349cbe7304 to your computer and use it in GitHub Desktop.
Save thejmazz/6735254e107432cb0c8716349cbe7304 to your computer and use it in GitHub Desktop.
Docker links

Docker

docker-cheat-sheet

  • Make a container that normally exits keep running as daemon: docker run -d imageName tail -f /dev/null

Links

Riot Games Engineering

dockerjenkins_tutorial

  1. Thinking Inside the Container
  2. Putting Jenkins in A Docker Container
  3. Docker and Jenkins: Data that Persists
  4. Jenkins, Docker, Proxies, and Compose
  5. Taking Control of Your Docker Image
  6. Building With Jenkins Inside an Ephemeral Docker Container
  7. Containerized Jenkins Farm Tutorial

Images

Build a named image from a Dockerfile in the current directory:

docker build -t name .

Volumes

Get names of orphaned docker volume containers:

docker volume ls -qf dangling=true

and remove:

docker volume rm $name

Backup stuff from inside a named volume container:

docker run --rm --volumes-from dbstore -v $(pwd):/backup ubuntu tar cvf /backup/backup.tar /dbdata

and then restore:

docker run -v /dbdata --name dbstore2 ubuntu /bin/bash
docker run --rm --volumes-from dbstore2 -v $(pwd):/backup ubuntu bash -c "cd /dbdata && tar xvf /backup/backup.tar --strip 1"

Images

Clean images:

docker rmi `docker images -q -f "dangling=true"`

Remove all untagged images:

docker rmi `docker images | grep "\s<none>" | awk '{print $3}'`
# or
docker rmi $(docker images -q --filter "dangling=true")

Stop all

docker stop $(docker ps -a -q)

Forcefully delete last 16 images. RIP my images when I ran this a second time by accident.

docker rmi -f `docker images --format "{{.ID}}" | tail -n +1 | head -n 16`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment