Docker Cheat Sheet

Below is a list of common and useful commands for working with docker.

List all images in local machine

docker image ls

List all running instances

docker ps -a

Stop/remove all docker images

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

Run a container from Docker Windows using .NET Core image

docker run --rm -it -v "$(pwd):/app" -p 5000:5000 mcr.microsoft.com/dotnet/core/sdk

(Notice the double-quotes around path, otherwise pwd will not work from Windows)

Run a container with Redis

docker run --rm -it -p 6379:6379 redis

Get into a running container

docker exec -it 55ff7be44aba /bin/bash

(Replace 55ff7be44aba with the actual container name or id)

 

Ref: