Skip to content

alexkast/docker-masterclass

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Docker Master Class

This repository is a todo application for the Docker Master Class.

The application is based on the application from the Getting Started tutorial at https://github.com/docker/getting-started



Task 00 - Demonstration of Working Linux Namespaces and Cgroups

Create basic docker image

docker build -t sleep-alpine  -<<EOF
FROM alpine
ENTRYPOINT ["sleep"]
CMD ["3600"]
EOF

Run sleep-alpine container

docker run --name sleep-alpine --memory=100m --cpus=".2" -d sleep-alpine

Connect to sleep-alpine container

docker exec -it sleep-alpine /bin/sh

Display namespaces

sudo lsns

Connect to alpine-sleep namespaces

sudo nsenter -t <container_pid> --pid --net --mount --ipc --uts sh

Check container_id

sudo systemd-cgls

Go to alpine-sleep container cgpoup folder

cd /sys/fs/cgroup/system.slice/docker-<container_id>

Check alpine-sleep container Memory limit in Mb

cat memory.max | awk '{$1=$1/1024/1024; print}'

Check alpine-sleep container CPU limit

cat cpu.max

Task 01 - Build an Image Based on Ubuntu

Build image

docker build --no-cache -t todos-app-task-01 -f task01/Dockerfile .

Run container

docker run -dp 3000:3000 --name todos-app-task-01 todos-app-task-01

Cleanup

docker stop todos-app-task-01 && docker rm todos-app-task-01

Task 02 - Build an Image Based on Ubuntu with Optimized Layers

Build image

docker build --no-cache -t todos-app-task-02 -f task02/Dockerfile .

Run container

docker run -dp 3000:3000 --name todos-app-task-02 todos-app-task-02

Cleanup

docker stop todos-app-task-02 && docker rm todos-app-task-02

Task 03 - Build an Image Based on Ubuntu with Optimized Layers and Cleanup Cache

Build image

docker build --no-cache -t todos-app-task-03 -f task03/Dockerfile .

Run container

docker run -dp 3000:3000 --name todos-app-task-03 todos-app-task-03

Cleanup

docker stop todos-app-task-03 && docker rm todos-app-task-03

Task 04 - Build an Image on Node Alpine

Build image

docker build --no-cache -t todos-app-task-04 -f task04/Dockerfile .

Run container

docker run -dp 3000:3000 --name todos-app-task-04 todos-app-task-04

Cleanup

docker stop todos-app-task-04 && docker rm todos-app-task-04

Task 05 - Build an Image on Node Alpine with Optimized Layers and Security Enhancements

Build image

docker build --no-cache -t todos-app-task-05 -f task05/Dockerfile .

Run container

docker run -dp 3000:3000 --name todos-app-task-05 todos-app-task-05

Cleanup

docker stop todos-app-task-05 && docker rm todos-app-task-05

Task 06 - Multi-Stage Build with Docker Volume Demonstration

Build image

docker build --no-cache -t todos-app-task-06 -f task06/Dockerfile .

Create docker volume

docker volume create todo-db

Run container with volume

docker run -dp 3000:3000 --mount type=volume,src=todo-db,target=/etc/todos --name todos-app-task-06 todos-app-task-06

Cleanup

docker stop todos-app-task-06 && docker rm todos-app-task-06 && docker volume rm todo-db

Task 07 - Docker Compose Demonstration

Create file with MySQL credentials

Note

Change the MYSQL_PASSWORD to your own

cat << EOF > .env
MYSQL_HOST=mysql
MYSQL_USER=root
MYSQL_PASSWORD=<DBPassword>
MYSQL_DB=todos
EOF

Run docker compose

docker-compose up -d

Cleanup

docker-compose down

About

Demo application for docker workshop

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published