Index

Installing Docker under Linux (Ubuntu / Mint)

Download the latest version of docker here (pool/stable):
https://download.docker.com/linux/ubuntu/dists/
If you need to know the Ubuntu release name for a version, you can find it here:
https://wiki.ubuntu.com/Releases
Likewise for Linux Mint:
https://www.linuxmint.com/download_all.php
hello world
sudo docker run hello-world
uninstall docker
sudo apt remove docker docker-engine docker.io containerd runc

using docker

show general info
sudo docker info
show running containers
sudo docker ps
create and start new container
sudo docker run [image]
start an existing container
docker start [id]
open linux shell to container
sudo docker exec -it [container_id] bash
stop container (find container_id using docker ps)
sudo docker stop [container_id]
remove image
docker rm -f [name]
update docker image
sudo docker pull [image]
list volumes
docker volume ls
get info on volume
docker volume inspect [volume_name]
remove volume
docker volume rm [volume_name]

docker run (new container)

run interactive linux docker
sudo docker run -it ubuntu bash
interactive (pseudo-TTY)
-it
automatically remove container and associated file system on exit
--rm
name a container
-- name [name]
assign an environment variable
-e [name]=[value]
launch in background (detached)
-d
bind image port to host
-p 5432:5432
make port available to localhost only
-p 127.0.0.1:5432:5432
mount persistent volume on image
-v [host_dir]:[image_dir]
start container every time docker starts
--restart

docker images

microsoft/mssql-server-linux
postgres
ubuntu

Postgres image

pull latest stable
docker pull postgres
pull specific version
docker pull postgres:[postgres_version]
run image
docker run --name postgres -e POSTGRES_PASSWORD=[password] -e POSTGRES_DB=[database_name] -p 127.0.0.1:5432:5432 -v [persistent_dir]:/var/lib/postgresql/data  postgres
environment variables
POSTGRES_PASSWORD=super user password
POSTGRES_USER=super user name
POSTGRES_DB.POSTGRES_USER=super user name
POSTGRES_DB=default database, defaults to [POSTGRES_USER]
documentation
https://docs.docker.com/samples/library/postgres/