Installing docker on Ubuntu

wget -q0- | sh

The basics

To add user(s) to the docker group
sudo usermod -aG docker
To check docker version
docker version
To get other information about your docker install
docker info
Using docker on Ubuntu
running an image
docker run hello-world
docker processes current
docker ps
docker processes all
docker ps -a
locally available docker images
docker images
get a docker image from the docker registry without running it
docker pull
remove a docker image from the local repository
docker rmi
To stop or start containers
docker stop
docker start
Delete containers
docker rm
Delete images
docker rmi

starting docker images with more control

docker run --name some-nginx -d -p 8080:80 some-content-nginx
Then you can hit http://localhost:8080 or http://host-ip:8080 in your browser
To stop all running docker containers
docker stop $(docker ps -aq)
disconnect from a container, but leave it running
Ctrl + p + q
attach to a running container
docker attach

Options used in the run command

-d detached, i.e. don’t attach it to my terminal, but run it in the background
–name give it a unique name, that way you can run many instances by identifying them by name
-p map a port. Nginx runs by default on port 80, but here we request that docker uses 8080 instead
-it open in stream and assign a terminal