# udemy_docker
https://www.youtube.com/watch?v=i7ABlHngi1Q&t=1903s
https://hub.docker.com/_/python

https://www.udemy.com/course/learn-docker/learn
april 12, section 4 / part 20

-- section 1

container vs vm
container lightweight and do not host an OS
container contains software and src

docker image = template
docker hub = public templates
docker container = running isolated instance
dockerFile = instructions

commands

docker run = run a container on the host by searching for a image, if not available, image is downloaded from docker hub.

docker ps = list current running containers
docker ps -a = list all including stopped containers

docker stop [container name] = stop container

docker rm [container name] = remove container

docker images = list available images on host

docker rmi [image name] = remove image

docker pull [image name] = download image


container directly exits when task is completed

# execute command on running container
docker exec [container name] cat /etc/hosts

docker run [container name] = in attach mode, terminal is attached to container
docker run -d [container name] = in detach mode, run in background

docker attach [container id / name?]

docker run -it ubuntu bash

-- ..

images with os downloaded to host
container uses image

# run container in background
docker run -d ubuntu sleep 100

-- section 3

docker run ubuntu:18.04 = os with tag / if not provided, default is latest

docker run -i(nteractive) -t(erminal) [name] = attached to terminal interactively

port mapping

- every container get an ip address (only internal / available on host)
- docker host or docker engine (same?); docker desktop is an engine / host?
- docker host has an ip address: you can map the ports of the host to the ports of your containers running on the host

volume mapping

- if you want te persist data, map your data folder to a folder on the host that persists
- docker run -v /path/to/data:/var/lib/mysql mysql

inspect container

docker inspect [name container] = more info, returns json format info

docker logs [container name] = log on standard out

# check release info
docker run ubuntu cat /etc/os-release


-- section 4: docker images



FROM Ubuntu = instruction + argument

all Dockerfiles should start with FROM


docker build . = build image using instructions from dockerfile

docker history [image name] = see how image is build


docker build . -q(uit) -t(ag) bla




https://github.com/pugillum/eneco_docker_kubernetes_training
https://www.udemy.com/course/python-in-containers/
https://www.udemy.com/course/learn-devops-the-complete-kubernetes-course/
https://kubernetes.io/docs/tutorials/kubernetes-basics/


prep work:

----

meeting met frank over smart-boiler-repair

# forward a port to a pod
kubectl port-forward smart-repair-api-5c7f464bc4-fh8x9 8000:8000

# show all resources
kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get --show-kind --ignore-not-found -n smart-boiler

# get details on current cluster
kubectl config current-context

# get clusters on activated environment
az aks list

# get available azure subscriptions
az account subscription list

# get namespaces in current context
kubens / kubectl get namespace

# check specific namespace
kubectl get pods --namespace dsp-acc

# show all resources in namespace
kubectl api-resources --verbs=list --namespaced -o name | xargs -n 1 kubectl get --show-kind --ignore-not-found -n smart-boiler

# apply config to k8s
kubectl kustomize blabla/overlay/a | kubectl apply -f -

# delete pod (will restart)
kubectl delete pod <pod-name>

# get deployment identifiers
kubectl get deployments --all-namespaces (or --namespace <namespace_name>)

# delete specific deployment including running pod
kubectl delete -n namespace deployment deployment

# forward a port to a pod
kubectl port-forward smart-repair-api-5c7f464bc4-fh8x9 8000:8000

# describe current resource
kubectl describe <resource> <resource_name> e.g. pod pod_name

----

youtube: https://www.youtube.com/watch?v=7bA0gTroJjw

kubectl (command line tool)

master node (4 tasks)
	- k8s api server
	- scheduler (devides work over pods)
	- controller manager
	- etcd

worker nodes -> pod(s) -> container(s)

kubects get nodes
kubectl get pods (-o -wide)
kubects delete pods {name_of_pod}
kubectl describe pods

file: deployment.yaml (instructions/manifest) --> manifest is desired state
	- specify e.g. number of containers, ports, resources, etc.

kubectl apply -f {name_of_manifest}.yaml = deploy manifest

k8s can scale out pods if CPU is above threshold

expose pods to outside world via api
'service' can be deployed by instructions in manifest
'service' is de facto a load balancer
- selector in yaml manifest determines the app it can access

kubectl describe services {name_of_service}

update your website or app by updating the manifest with new docker image and it will kill old and create new containers

----