Cheat Sheet - Docker

Cheat Sheet - Docker

Run Postgres locally

docker run -p 5432:5432 -v postgres-11-volume:/var/lib/postgresql/data --env POSTGRES_PASSWORD=postgres --name postgres-11 postgres:11 --restart=always

Push image to Azure Container Registry

az login 
az acr login --name myregistry
docker tag killerapp/backend myregistry.azurecr.io/killerapp/backend
docker push myregistry.azurecr.io/killerapp/backend

Verify a docker installation

docker run -it hello-world 
docker run -it -p <localPort>:<containerPort> <image>

Build and tag image

docker build -t killerapp/backend:dev .

List running containers

docker container ls

Run container interactively and remove it afterward

docker run -it --rm image:tag sh
docker run --interactive --tty --rm image:tag sh

List local images

docker image ls

Inspect image content

# First option 
docker run -it <image-name> sh

# Second option
docker run -it --entrypoint sh <image-name>

# Third option
docker image history --no-trunc <image-name> > image_history