Skip to content

Instantly share code, notes, and snippets.

@Alexisvt
Last active January 5, 2022 23:45
Show Gist options
  • Save Alexisvt/6bc90d22c5a0dbaa706abd1e923940cb to your computer and use it in GitHub Desktop.
Save Alexisvt/6bc90d22c5a0dbaa706abd1e923940cb to your computer and use it in GitHub Desktop.
Just a random set of commands for Docker and Kubernetes

Docker and Kubernetes commands

Docker commands

This build an image base on a Dockerfile and assign a tag to it and a version number

docker build -t custom/tag:0.0.1 .

Create and start a container based on the provided image id or tag

docker run [image id or image tag]

Create and start container, but also override the default command

docker run -it [image id or image tag] [cmd]

Print out information about all of the running containers

docker ps

Execute the given command in a running container

docker exec -it [container id] [cmd]

Print out logs from the given container

docker logs [container id]

Kubernetes commands

Fetchs all the running pods within a cluster

kubectl get pods

This create a pod base on a YML config file

kubectl apply -f posts.yml

Print out information about all of the running pods

kupecti get pods

Execute the given command in a running pod

kubectl exec -it [pod_name] [cmd]

Print out logs from the given pod

kubectl logs [pod_ name]

Deletes the given pod

kubecti delete pod [pod_name]

Tells kubernetes to process the config

kubecti apply -f [config file name]

Print out some information about the running pod

kubectl describe pod [pod_name]

Sample for a config file

apiVersion: v1
kind: Pod
metadata:
  name: posts
spec:
  containers:
    - name: posts
      image: alexisvt/posts:0.0.1

Adding autcomplete and shortcut k to zsh

# somewhere in your zshrc
plugins=(git git-flow history node npm kubectl)

Source: Autocompletion for kubectl and aliases using oh-my-zsh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment