# 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