Home Linux Containers
Show docker version

docker --version
docker version
docker info


docker --help
docker container --help

Show running containers

docker ps 
docker container ls

Show all containers ( includes failed runs )

docker container ls -a

Search an image (alpine)

docker search alpine

Show available versions for apline

curl 'https://registry.hub.docker.com/v2/repositories/library/alpine/tags/'|jq '."results"[]["name"]'

Download  an image
docker pull alpine:3.8

List the images

docker image ls

Create an image from a base
  vim myImage

FROM alpine:3.8
COPY . /app
CMD /app/hello.sh

Build an image

docker build -t NAME:TAG -f DOCKERFILE .

View the layers

docker history IMAGE_ID

Run an image

docker run -dit --name NAME:TAG
                --restart  no|on-failure|unless-stopped|always

d  Run container in background and print container ID 
i  Keep STDIN open even if not attached
t  Allocate a pseudo-TTY

Run an image and map a port

docker run -d -p 8080:80 NAME:TAG

Attach to a runing image

docker attach CONTAINER_ID 

Stop an image

docker container stop  CONTAINER_ID
docker container kill  CONTAINER_ID

Remove a container 

docker image rm IMAGE_ID

Get all containers id on this machine

docker image ls -a -q