We mostly use 101 course from https://www.docker.com/101-tutorial ============================================== OS-level virtualization https://en.wikipedia.org/wiki/OS-level_virtualization ============================================== Docker: https://en.wikipedia.org/wiki/Docker_(software) SW: Docker Daemon Docker client program ---------------------- Objecs: Docker container Docker image Docker service (we will not speak about this today) ---------------------- Registries: Docker registry (main ones: default one Docker Hub and Docker Cloud) -------------------------------------------------- Tools: Docker Dashboard Docker Compose Docker Swarm (we will not speak about this today) =================================================== =================================================== Child commands https://docs.docker.com/engine/reference/commandline/docker/ =================================================== Working with docker command: - Run Ubuntu container with bash docker run -it ubuntu docker run -it ubuntu echo AAA - Run docker tutorial command (in docker) This demonstrates port mapping =================================================== Very basic Workflows docker images Dockerfile docker build -t getting-started . docker ps docker run -dp 3000:3000 getting-started docker stop docker rm docker rm -f =================================================== Docker volumes - Named volumes docker volume create todo-db docker run -dp 3000:3000 -v todo-db:/etc/todos getting-started docker volume inspect todo-db =================================================== Docker volumes - Bind Mounts docker run -dp 3000:3000 \ -w /app -v "$(pwd):/app" \ node:12-alpine \ sh -c "yarn install && yarn run dev" =================================================== Docker networking docker network create todo-app docker run -d \ --network todo-app --network-alias mysql \ -v todo-mysql-data:/var/lib/mysql \ -e MYSQL_ROOT_PASSWORD=secret \ -e MYSQL_DATABASE=todos \ mysql:5.7 docker run -dp 3000:3000 \ -w /app -v "$(pwd):/app" \ --network todo-app \ -e MYSQL_HOST=mysql \ -e MYSQL_USER=root \ -e MYSQL_PASSWORD=secret \ -e MYSQL_DB=todos \ node:12-alpine \ sh -c "yarn install && yarn run dev" =================================================== Docker Compose docker-compose.yml docker-compose up -d docker-compose logs docker-compose down (--volumes) =================================================== Layers and good practices How layers work, Layer caching Good practices writing Dockerfile docker image history docker scan getting-started =================================================== Docker registry docker tag getting-started YOUR-USER-NAME/getting-started docker push YOUR-USER-NAME/getting-started =================================================== Discuss typical use cases: Production - clean and well defined enviroment - you want to test in a clone of production enviroment, containers help a lot with this - standardized format that allows to other tools (e.g. container orchestration) Build - do need to setup build dependencies - you can test in well defined enviroment https://www.airpair.com/docker/posts/8-proven-real-world-ways-to-use-docker =================================================== Insights into how the containers work: https://www.youtube.com/watch?v=8fi7uSYlOdc ===================================================