Docker Commands

docker build

  • docker build -t service-name:latest .

Builds docker image with repository name service-name, latest and current context

  • docker build -t whenry/fedora-jboss:latest -t whenry/fedora-jboss:v2.1 .

Builds docker image with repository name service-name, latest and current context

docker image

  • docker images -a

List all the docker images.

  • docker rmi image-id

Removes specified image

  • docker rmi $(docker images -a -q)

Removes all images.

docker ps

  • docker ps -a

List all the docker containers.

  • docker stop container-id

Stops specified docker container.

  • docker rm container-id

Removes specified docker container.

  • docker stop $(docker ps -a -q)

Stop all running containers.

  • docker rm $(docker ps -a -q)

Remove all running containers.

docker exec

  • docker exec -it container-id /bin/sh

Inspects inside docker container.

docker log

  • docker log container-id

Prints container logs.

  • docker log -f container-id

Tails container logs.