Malcolm 'Max' DeRungs

Docker

Install

Windows 10

See https://docs.docker.com/docker-for-windows/

Linux Ubuntu

Install Docker Engine and Docker Compose separately:
See https://docs.docker.com/engine/install/ubuntu/
See https://docs.docker.com/compose/install/

Commands

Commands can be run from Bash or PowerShell.

Help
<cmd> --help
<cmd> --version
Pull

Get the latest image of Ubuntu server off of Docker Hub

docker pull ubuntu:latest

Get the a specific version of Ubuntu server off of Docker Hub by tag name

docker pull ubuntu:18.04
Run
docker run hello-world
docker run --interactive --tty ubuntu bash
docker run --detach --publish 80:80 --name webserver nginx
docker run -p 8983:8983 -t solr

Name a container and run it in detached mode

docker run -p 8983:8983 -t solr --name solr -d
Images

List images

docker images
docker image ls

List images without a tag name

docker images -f “dangling=true” -q

Remove image

docker image rm wordpress:latest php:latest
docker image prune -a
Volumes

List volumes

docker volume
Remove volumes
docker volume prune
Networks

List networks

docker network

Remove networks

docker network prune
Containers

List containers

docker ps
docker container ls
docker container ls --all
docker ps -aq

Stop containers

docker container stop webserver
docker stop $(docker ps -aq)
sudo docker stop $(sudo docker ps -aq)

Remove containers

docker container rm webserver laughing_kowalevski relaxed_sammet
docker rmi -f c0fdfb66599d
docker rm $(docker ps -aq)
sudo docker rm $(sudo docker ps -aq)
Exec

Access bash shell of Docker app

docker exec -it appname bash
Build

See https://docs.docker.com/engine/reference/commandline/build/

Commit

Commit a build to Docker Hub Repository

docker commit df75aa301d62 ubuntu:18.04vim
Compose
docker-compose up -d
docker-compose --verbose up