Docker

Basic

Build image

docker build -t registry/repo:tag .

Create an image from a Dockerfile.

Push image

docker push -t reigstry/repo:tag

Run container

On daemon

docker run -d -p LOCAL_PORT:CONTAINER_PORT -v LOCAL_DIR:CONTAINER_DIR -e ENV=somthing registry/repo:tag

Auto completion

Add docker plugin to ~/.oh-my-zsh/plugins/docker/_docker and check ~/.zshrc

plugins=(git 
docker
)
fpath+=($ZSH/plugins/docker)
autoload -U compinit && compinit

See stackoverflow and docker docs

Containers

Interact with container

docker exec -it CONTAINER_NAME_OR_ID /bin/bash 

Run commands in a container.

Automatically remove the container when it exits

docker run -rm -it registry/repo:tag /bin/bash

Images

Manage images

$ docker images
  REPOSITORY   TAG        ID
  ubuntu       12.10      b750fe78269d
  me/myapp     latest     7b2431a8d968
$ docker images -a   # also show intermediate

Manages images.

Remove container

docker rmi CONTAINER_ID_OR_NAME

Deletes images.

Export and import image

docker save imagename > imagename.tar
docker load -i imagename.tar

Also see