Skip to content

Instantly share code, notes, and snippets.

@adamghill
Created May 25, 2024 17:44
Show Gist options
  • Save adamghill/724ecf520ada71605fd6fa355ab864c3 to your computer and use it in GitHub Desktop.
Save adamghill/724ecf520ada71605fd6fa355ab864c3 to your computer and use it in GitHub Desktop.
Useful docker CLI commands that I always forget

Note: IMAGE_NAME should be replaced with some unique name.

  • Build the Dockerfile in the current directory: docker build -t IMAGE_NAME .
  • Get the size of the resulting Docker image: docker image save IMAGE_NAME | wc -c | numfmt --to=si
  • Run the resulting Docker image for web apps: docker run -p 127.0.0.1:80:3000 IMAGE_NAME
  • Open a shell in a Docker image: docker run -it --rm IMAGE_NAME /bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment