Skip to content

Instantly share code, notes, and snippets.

@hodrigohamalho
Last active August 29, 2015 14:19
Show Gist options
  • Save hodrigohamalho/f9b144e221c3fdef4777 to your computer and use it in GitHub Desktop.
Save hodrigohamalho/f9b144e221c3fdef4777 to your computer and use it in GitHub Desktop.
Docker Cheat Sheet

Docker

docker search -s 1 fedora
  • -s = number of image at least N stars

  • --no-trunc=true prints full image description

Download Image

Once a image has been found, use:

docker pull fedora

For loading container images locally use:

docker load -i rhel-server-docker.tar.gz

Display Locally Available Images

docker images

Save a container image

Is useful to backup custom images and transport images from one container to another without a registry.

docker save fedora:21 > /var/tmp/fedora-21.tar

Remove a local image

docker images                      # to list
docker rmi repository:tag|IMAGE ID # syntax
docker rmi fedora:rawhide          # example

Tagging an image

docker tag 8346237842c fedora/training:21-training

Stop and remove all containers

docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)

It will generate a REPOSITORY called fedora/training and a tag 21-training poiting to the same image id.

Lauching a container

docker run -i -t fedora /bin/bash
  • -i tells docker to give an interactive shell

  • -t allocate a pseudo-tty

Enter in a running container

docker exec -it [container-id] bash

To external access

sysctl -a | grep ip_forward
net.ipv4.ip_forward = 1

Kubernetes

Helper commands

Generate load on server:

yum install -y httpd-tools
ab -n 100 -c 10 http://url:8080

Show bridge networks:

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