Skip to content

Instantly share code, notes, and snippets.

@interisti
Last active February 19, 2023 03:49
Show Gist options
  • Save interisti/3e73a3d6be7de53053bc067858b3ba58 to your computer and use it in GitHub Desktop.
Save interisti/3e73a3d6be7de53053bc067858b3ba58 to your computer and use it in GitHub Desktop.
docker cheat sheet

DOCKER

list images with size

docker images | awk '{print $1"\t"$2"\t"$7" "$8}'

list running containers

docker ps

list all running containers

docker ps -a

stop all containers

docker stop $(docker ps -a -q)

delete all containers

docker rm $(docker ps -a -q)

delete image

docker rmi <image name>

delete all images

docker rmi $(docker images -a -q)

attach to container

docker exec -t -i <container id> /bin/bash

Docker-Compose

build

docker-compose build

build (no cache)

docker-compose build --force-rm --no-cache

run containers

docker-compose up

Docker-Machine

Create

docker-machine create --driver [virtualbox, amazonec2, digitalocean] <machine name>

Regenerate user certificates

docker-machine regenerate-certs <machine name>

list mahcines

docker-machine ls

switch to machine terminal

eval "$(docker-machine env <machine name>)"

connect to existing host

docker-machine create --driver generic --generic-ip-address <ip> --generic-ssh-user <username> --generic-ssh-key <key-location> <machine name>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment