🐬Docker Cheat Sheet
Docker is an open platform for developing, shipping, and running applications. Below cheat sheet for quickly brush up docker cli commands.
Docker Commands
Login
docker login -u "your username" -p "your password" docker.io
Build Docker File
To be executed in the root directory of 'DockerFile'
docker build --tag geo-location-app:v0.1 .
// First in the command you should be in the path of the file name 'SQLAPI-Dockerfile'
docker build --tag fx-data-apis-app:v0.1 -f SQLAPI-Dockerfile .
Push Image to hub.docker.com
Option 1
docker tag 116e178f6fc5 ganeshramsr/geolocationapi:v0.1
docker login docker.io docker push ganeshramsr/geolocationapi:v0.1
Option 2:
docker tag 338f61b0d9c7
ganeshramsr/geo-loc-api:v0.1 docker push ganeshramsr/geo-loc-api:v0.1
docker tag 2ea41a89aa54
ganeshramsr/geo-loc-api:v0.2 docker push ganeshramsr/geo-loc-api:v0.2
To Run Docker image
Simple Docker Run
docker run -p 5050:80 --name <containername> <imagename>
Run docker image with environmental variable
docker run -it -d -p 5050:80
-e ASPNETCORE_URLS=http://+:80
--name containername imagename
docker run --rm -it -p 49853:80/tcp
-e GEO_API_URL='http://localhost:40051/' 1b37dbb57268
Run in 2 different ports
docker run --rm -it -p 49854:443/tcp -p 49853:80/tcp 1b37dbb57268
// Run Mongo DB Container with Volume Attached
docker run -d -p 27017:27017 --name mongo-db-container
-v C:/Data/MongoDb-Data:/data/db -d mongo:latest
// Run SQL Server with SA, Password
docker run --name SQLServer2022
-e "ACCEPT_EULA=Y"
-e "MSSQL_SA_PASSWORD=System@1984"
-p 1433:1433 -d mcr.microsoft.com/mssql/server:2022-latest
Many times TCP Wont work, because of certificate issue.
Remove Actions
To remove Image/Container
docker image prune --filter="dangling=true"
docker image rm b01823902874
docker image rm b01823902874 -f
docker container prune //Remove all unused containers
Container Actions
// Starts the existing container
docker container start mongo-db-container
//Extract Docker image and save it as '.tar' file.
docker save --output busybox.tar 3ca38f187e93
// Inspect the running container
docker inspect 'container-id'
docker stop c15198355ebd
Primary Full Cheat Sheet for Docker CLI

Last updated
Was this helpful?