Installing Docker under Linux (Ubuntu / Mint)

Download the latest version of docker here (pool/stable):
If you need to know the Ubuntu release name for a version, you can find it here:
Likewise for Linux Mint:
hello world
sudo docker run hello-world
uninstall docker
sudo apt remove docker docker-engine containerd runc

using docker

show general info
sudo docker info
show running containers
sudo docker ps
show ALL containers
sudo docker ps -a
sudo docker ps --all
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]
copy from host to container
docker cp [file] [container]:[path]
copy from container to $pwd on host
docker cp [container]:[path] .
copying files between containers is not supported

docker run (new container)

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

docker network

list networks
docker network ls
create a new network
docker network create [network]
delete network (disconnect containers first)
docker network rm [network]
connect container to network
docker network connect [network] [container]
disconnect container from network
docker network disconnect [network] [container]
examine network details
docker inspect [network]

docker images

common images
image hub

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 -v [persistent_dir]:/var/lib/postgresql/data  postgres
environment variables
POSTGRES_PASSWORD=super user password
POSTGRES_USER=super user name
POSTGRES_DB=default database, defaults to [POSTGRES_USER]

Java image

java hello world
sudo docker run --rm openjdk java -version
mounting and running an application
sudo docker run --rm -v "$PWD":/app -w /app openjdk java -jar [jar]
sudo docker run --rm -v "$PWD":/app openjdk java -jar app/[jar]

Apache image

Apache hello world
sudo docker run --rm -p 80:80 httpd
mount document root
sudo docker run --rm -p 80:80 -v [dir]:/usr/local/apache2/htdocs/ httpd:2.4
reload config
docker cp httpd.conf [container]:/usr/local/apache2/conf/httpd.conf
docker exec -it [container] apachectl graceful

Jenkins image

Jenkins hello world
docker run --network bridge --publish 8080:8080 --rm jenkins/jenkins