Skip to content

Instantly share code, notes, and snippets.

@iacoware
Last active September 5, 2020 14:25
Show Gist options
  • Save iacoware/eeba37fa75985881be6cb93e2923bb1b to your computer and use it in GitHub Desktop.
Save iacoware/eeba37fa75985881be6cb93e2923bb1b to your computer and use it in GitHub Desktop.

Run an app inside docker using only 2 cores (0,1). Mount current directory

docker run --rm -it --cpuset-cpus 0-1 -v $(PWD):/app/ -w /app/ mcr.microsoft.com/dotnet/core/sdk:2.2 dotnet run 1

Run asp.net core inside docker with mounted volume

docker run --rm -it -p 5000:5000 -v ~/my-app/src/app/:/app/ -w /app/ -e ASPNETCORE_URLS=http://+:80 mcr.microsoft.com/dotnet/core/sdk:2.2 dotnet watch run

Attach interactively

docker exec -it <CONTAINER ID> /bin/bash

Remove dangling images

docker rmi $(docker images -f dangling=true -q)

Remove all stopped container

docker rm $(docker ps -q -f "status=exited")

see more at https://andrewlock.net/handy-docker-commands-for-local-development-part-2/

Check content of an image (explore folders)

docker run -it <image_name> sh if the image uses CMD

docker run -it --entrypoint sh <image_name> if the image uses ENTRYPOINT

Others

docker builder prune clear build cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment