Docker Cheat Sheet
- --env-file <file> provides all environment variables which are contained in <file>
- However, the file content differs from that of a bash script which can be launched with
source <file.sh>
:
$ cat env.list
# This is a comment
VAR1=value1
VAR2=value2
USER
This file should use the syntax <variable\>=value
(which sets the variable to the given value) or <variable\>
(which takes the value from the local environment), and #
for comments.
NOTE: see https://docs.docker.com/engine/reference/commandline/run/
- Use --net host if the following applies
- container is running locally
- container shall be reachable via its IP address
- Access with localhost:8081/api/v0/feed for udagram-feed
- login to a running container
docker exec -it <container name> /bin/bash
to get a bash shell in the container
- log into a NOT running container
docker run -it --rm --entrypoint sh udagram-feed
NOTE: see https://thorsten-hans.com/how-to-run-commands-in-stopped-docker-containers
docker run --env-file ../env.list --net host udagram-feed
- Either (XOR)
- Configure container with
EXPOSE 8080
in its Dockerfile - Run the container with
docker run -p 8100:80 <container name>
- Configure container with
docker build -t <container name> .
will run the Dockerfile to create an imagedocker run <IMAGE_ID>
will run a container with the imagedocker images
will print all the available imagesdocker ps
will print all the running containersdocker kill <CONTAINER_ID>
will terminate the containerdocker exec -it <container name> /bin/bash
to get a bash shell in the running containerdocker run --env-file ../env.list --net host udagram-feed
to get a shell in the NOT running containerdocker container inspect [OPTIONS] <container id> [CONTAINER...]
get metadata about mentioned container(s)
# installing node's package dependencies
npm install
# doing a test drive
npm run dev
# build the project for the container, output is in www folder
npm run build
# build the container
docker build -t udagram-feed .
# run it by configuring environment variables and using hosts IP address
docker run --env-file ../env.list --net host udagram-feed
- https://knowledge.udacity.com/questions/217758
- https://knowledge.udacity.com/questions/397631
- https://knowledge.udacity.com/questions/192623
aws s3 ls momi-303817241937-dev
to list the content of given bucketaws s3 rm s3://momi-303817241937-dev/tea.jpg
to remove given file
- Pairing local cli with EKS:
aws eks --region eu-central-1 update-kubeconfig --name DemoCB
NOTE
docker tag <container name> <repo name>
docker login --username=finfalter
docker push finfalter/udagram-feed
kubectl get pods
kubectl logs ${POD_NAME} -p
kubectl describe pod ${POD_SHORT_NAME}
https://kubernetes.io/docs/tasks/debug-application-cluster/get-shell-running-container/
kubectl exec <ID> --stdin --tty /bin/bash
kubectl delete -n NAMESPACE deployment DEPLOYMENT
e.g. kubectl delete -n default deployment udagram-feed
kubectl delete --all pods --namespace=default
echo "changing location"
cd ~/dev/udacity/cloud-developer/03-microservices/src/project/udagram-microservices
kubectl delete all --all -n default
# create a secret
# https://kubernetes.io/docs/tasks/configmap-secret/managing-secret-using-config-file/
kubectl apply -f ../../aws-secret.yml
# create a configuration map
# https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/
kubectl create configmap udagram-env --from-env-file=./env.list
kubectl apply -f udagram-feed/deploy/deployment.yml
kubectl apply -f udagram-feed/deploy/service.yml
kubectl apply -f udagram-user/deploy/deployment.yml
kubectl apply -f udagram-user/deploy/service.yml
kubectl apply -f udagram-frontend/deploy/deployment.yml
kubectl apply -f udagram-frontend/deploy/service.yml
kubectl apply -f udagram-reverse-proxy/deploy/deployment.yml
kubectl apply -f udagram-reverse-proxy/deploy/service.yml
kubectl get secret aws-secret -o yaml
kubectl get configmap udagram-env -o yaml
kubectl get pods
kubectl autoscale deployment <NAME> --cpu-percent=<CPU_PERCENTAGE> --min=<MIN_REPLICAS> --max=<MAX_REPLICAS>
kubectl get hpa
# https://stackoverflow.com/questions/44110876/kubernetes-service-external-ip-pending
minikube service --url udagram-frontend
kubectl port-forward udagram-reverse-proxy-64f66fd9d6-v4f8v 8080:8080
kubectl port-forward udagram-frontend-64f66fd9d6-v4f8v 8100:80
replace:
kubectl create configmap udagram-env --from-file ./env.list -o yaml --dry-run | kubectl replace -f -
echo -n 'hallo' | base64 echo -n 'bWF6ZGEzMjMK' | base64 --decode