Skip to content

Instantly share code, notes, and snippets.

@juddey
Last active December 8, 2017 00:29
Show Gist options
  • Save juddey/e4b98252d973287a996cf7fe666129b4 to your computer and use it in GitHub Desktop.
Save juddey/e4b98252d973287a996cf7fe666129b4 to your computer and use it in GitHub Desktop.
Docker
docker build -t friendlyname . # Create image using this directory's Dockerfile
docker run -p 4000:80 friendlyname # Run "friendlyname" mapping port 4000 to container port 80
docker run -d -p 4000:80 friendlyname # Same thing, but in detached mode
docker container ls # List all running containers
docker container ls -a # List all containers, even those not running
docker container stop <hash> # Gracefully stop the specified container
docker container kill <hash> # Force shutdown of the specified container
# Remove specified container from this machine
docker container rm $(docker container ls -a -q) # Remove all containers
# List all images on this machine
docker image rm <image id> # Remove specified image from this machine
docker image rm $(docker image ls -a -q) # Remove all images from this machine
docker login # Log in this CLI session using your Docker credentials
docker tag <image> username/repository:tag # Tag <image> for upload to registry
docker push username/repository:tag # Upload tagged image to registry
docker run username/repository:tag # Run image from a registry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment