Skip to content

Instantly share code, notes, and snippets.

@Holajuwon
Last active April 21, 2023 12:58
Show Gist options
  • Save Holajuwon/593626667a176196828c90118c0d88ba to your computer and use it in GitHub Desktop.
Save Holajuwon/593626667a176196828c90118c0d88ba to your computer and use it in GitHub Desktop.

Docker commands

# build docker image with tag
$ docker build -t USERNAME/REPO .

# docker run
$ docker run -it container_id || image_name

# list all container
$ docker ps --all

# execute command in container
$ docker exec -it [container id] [cmd]

# gives logs from container
$ docker logs [container id]

# push to docker hub
$ docker push username/name

# Build command from docker-compose.yml
$ docker-compose -f 'docker-compose.yml' up -d --build

# Start docker compose after first build
$ docker-compose -f 'docker-compose.yml' up --build

Kubbernetes commands

# get all pods
$ kubectl get pods

# create pod/object
$ kubectl apply -f posts.yaml

# 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
$ kubectl delete pod [pod_name]

# Print out some information about the running pod
$ kubectl describe pod [pod_name]

# Deployments
$ kubectl get deployments

# create deployment/object
$ kubectl apply -f posts-depl.yaml

# Deletes the given deployment 
$ kubectl delete deployment [deployment-name]

# Print out some information about the deployment 
$ kubectl describe deployment [deployment-name]

# redployment
$ kubectl rollout restart deployment [deployment-name]

# Services
$ kubectl get services

# info about service
$ kubectl describe service [service_name]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment