A list of useful Docker, Kubernetes and Helm commands
Basic Docker container management
$ docker images- list locally cached images$ docker container ls- list running containers$ docker container stop containername- stop a running container$ docker container rm containername- remove a running container
Local Docker Registry
$ docker run --detach --publish 5000:5000 --restart=always --name=registry registry:2- run a local registry in the background
The first port number refers to the local host, the second is the port within the container.$ docker tag imagename localhost:5000/myimagename- To push to a particular registry, first tag the image with the first part as hostname:port.$ docker push localhost:5000/myimagename- push myimagename from the local docker cache to the local registry$ docker pull localhost:5000/myimagename- pull myimagename from the local registry to the local docker cache
Kubernetes
The official cheat-sheet is pretty detailed, the shortlist below are my "beginners basics":$ kubectl version$ kubectl get nodes$ kubectl config get-contexts$ kubectl config current-context$ kubectl config use-context$ kubectl config view$ kubectl get deployments$ kubectl delete deployment name$ kubectl get pods [-o wide|yaml|json|go-template=]- list deployed pod names$ kubectl get pod --watch pod-name- follow pod status changes$ kubectl describe pod/pod-name- print detailed pod status and event transitions - useful for start-up diagnostics$ kubectl delete pod/pod-name$ kubectl get services$ kubectl describe service name$ kubectl delete service -l run=name$ kubectl logs pod-name- print pod application logs$ kubectl exec -ti pod-name -- bash$ kubectl exec -ti pod-name -- curl localhost:8080
Helm
Helm is an 'orchestration' service. It co-ordinates all of those separate Kubernetes configurations that are required to set up your application. Essentially it allows you to write Kubernetes config files as templates, extracting the variables to a top-level 'values.yaml' file, supporting a level of re-use and abstracting away some of Kubernetes' complexity. You must still learn the Kubernetes API though, and now also some {{ Go }} syntax too...$ helm list- list deployments$ helm install [--debug] [--dry-run] chartdir- deploy the given chart to the cluster$ helm delete ...- opposite of install$ helm status ...- print deployment status
YAML
Of course, you also need to learn YAML syntax. This cheat-sheet is the most helpful I've found so far. Scroll down to the Examples section.The YAML spec website is a daunting place to start for something essentially so simple, but it does include a short refcard which may become useful once you know what it all means.