Skip to content

Instantly share code, notes, and snippets.

@cecyc
Created August 29, 2018 19:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cecyc/74a8fc1cde0bac3202a58f46e00f4acc to your computer and use it in GitHub Desktop.
Save cecyc/74a8fc1cde0bac3202a58f46e00f4acc to your computer and use it in GitHub Desktop.
A quick reference doc for Docker and Kubernetes for those starting out

Docker and Kubernetes cheatsheet

Docker

Basics

Basic commands:

  • docker ps list all currently running containers
  • docker-compose build build a series of containers based on a docker-compose file
  • docker-compose build %APP_NAME% only build a specific app or service from a docker-compose file
  • docker-compose up stand up a series of containers based on a docker-compose file
  • docker-compose up %APP_NAME% only stand up and run a specific service from a docker-compose file

I use these commands when I modify a docker-compose file and do not see the changes being applied:

  • docker-compose build --no-cache use a fresh image and not a locally cached image
  • docker-compose up --force-recreate recreate containers

A good alias candidate for recreating containers:

  • docker-compose down && docker-compose build --no-cache && docker-compose up

Kubernetes

Basics

Basic Kubernetes commands:

  • kubectl get po list all pods
  • kubectl get po -l app=NAME list all pods with a certain name
  • kubectl describe po NAME describe a pod
  • kubectl delete po NAME delete a specific pod
  • kubectl describe describe deployment NAME describe an entire deployment (i.e. a collection of pods)
  • kubectl edit deployment NAME edit a current deployment (this should open vi or default editor)
  • kubectl logs NAME get logs from a specific pod
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment