Useful Docker Commands

Build image

# the "-t" gives your image a name 
$ docker build -t YourImageName .

List Containers

# containers currently runing
$ docker ps -a

List Images

# list all docker images
$ docker images -a

Delete containers

# Delete every Docker containers
# Must be run first because images are attached to containers
$ docker rm $(docker ps -a -q)

Delete images

# Delete every Docker image
$ docker rmi $(docker images -q)

Force delete images

# to force use
$ docker rmi -f $(docker images -q)

Stop container

stop a container
$ docker stop <container id>

Shell in running container

# from docker 1.3 onwards
$ sudo docker exec -i -t <containerIdOrName> bash