Docker Basics
Images are stopped containers, containers are running images. Images are stored in a central repository called Docker Hub.
Login to Docker Hub:
docker login
Information about docker:
docker version
docker info
List the current running containers:
docker ps
List containers that have been run previously:
docker ps -a
List images saved locally:
docker images
Pull an image from Docker Hub:
docker pull ubuntu
docker pull ubuntu:14.04
Run an image, searching locally first and pulling from Docker Hub if not found:
docker run ubuntu
Run a container interactively:
docker run -it ubuntu
docker run -it ubuntu /bin/bash
Run a container detached (-d) with the name web (--name), mapping port 80 on the host to port 8080 in the container (-p):
docker run -d --name web -p 80:8080 nigelpoulton/pluralsight-docker-ci
Detach an interactive container to run in the background with CTRL-P + Q.
Stop a container by its name or id:
docker stop web
Stop all containers:
docker stop $(docker ps -aq)
Remove all containers:
docker rm $(docker ps -aq)
Remove all images
docker rmi $(docker images -q)