Install Docker Engine and Docker Compose separately:


Common commands run from Bash or PowerShell.
docker --version --> check version
docker system prune -a --> remove everything (except running)
docker ps -aq --> show all running processes (no prompt)



Build an image

docker build --tag imagename:tagname .
docker build --tag .

Commit build changes before push

docker commit buildnumber imagename:tagname

Pull, Tag, and Push an image

Pull image from repository
docker pull ubuntu:tagname
docker pull

Create a new tag
docker tag imagename:tagname1

Push image to repository
docker push

Backup and replace image in repository

docker pull && \
docker tag && \
docker push && \
docker build -t . && \
docker push
List images

docker images
docker image ls
docker images -f “dangling=true” -q

Remove image(s)

docker image rm 182712361A
docker image rm 182712361A 9934812348
docker image rm imagename:tagname
docker image prune -a

Beginning with:
docker rmi $(docker images -a | grep "^<none>" | awk '{print $3}')
docker rmi $(docker images -a | grep "^registryname" | awk '{print $3}')

Tagged with:
docker rmi $(docker images -a | grep "<none>" | awk '{print $3}')

Volumes & Networks


docker network create networkname


docker volume
docker network


docker volume prune
docker network prune



Run a container

-it --> interactive tty
-p --> publish outside:inside ports
-e --> environment variable
-d --> detached mode
--rm --> remove running container when closed
--name --> give running container an easy to remember name
--net --> map container to Docker network name

Run image and open interactive shell
docker run -it image:tagname /bin/bash

Use a variety of flags
docker run -e 'MARIADB_ROOT_PASSWORD=password' --name containername
docker run -p 1521:1521 --name containername imagename:tagname
docker run -d -p 80:80 --name containername imagename
docker run -d --rm --name containername imagename:tagname
docker run -d --rm -p 3306:3306 --net wp --name containername

Access command line of a container

docker exec -it containername /bin/bash
docker exec -it containername /bin/sh

Access command line of a container as root user

docker exec -it -u root containername /bin/bash
docker exec -it -u 0 containername /bin/bash

List containers

docker container ls
docker container ls -a
docker container ls --all

Stop, kill, and remove running container(s)

docker container stop containername
docker container kill containername

docker container rm containername
docker container rm containername1 containername2 relaxed_sammet

More than one by variable
docker stop $(docker ps -aq)
docker rm $(docker ps -aq)

Get serious
docker container prune -a


docker-compose up -d
docker-compose --verbose up
Docker-Compose - restart a service locally
docker-compose kill $s && 
docker-compose rm -f $s && \
docker-compose build $s && \
docker-compose up -d && \
docker-compose logs -f $s
Access command line of a container

docker-compose exec containername /bin/bash