How to containerize your monolith and/or microservices using Docker
Anton Antonov
Questions that are going to be addressed:
- What's Docker?
- What's really Docker?
- Docker container vs Virtual machine - what's better?
- How to create a Docker container?
- What's Docker-Compose?
- What's Docker-Machine?
- How to orchestrate services using Docker-compose
- How to run Hype CRM, Picard, Sidious in containers and every modern OS (incl. Windows)?
What's Docker?
It's actually a company that was previously called dotCloud.
It started off as a side-project and was only open-sourced recently in 2013.
What people commonly call Docker is actually the Docker Engine
What's Docker Docker Engine?
The Docker Engine is a:
- lightweight container runtime
- robust tooling that builds and runs your container.
What's Docker Docker Engine?
Docker Engine allows you to package up application code
and dependencies together in an isolated container
that share the OS kernel on the host system.
The in-host daemon communicates with
the Docker Client to execute commands to
build, ship and run containers.
What's really Docker
Docker Engine?
Docker Engine is really an extension of the
Linux Containers (LXC in short) capabilities.
What's really Docker
Docker Engine?
It provides a high-level API that provides a lightweight
virtualization solution to run processes in isolation.
What's really Docker
Docker Engine?
It's written in Go (therefore I love it) and also utilizes cgroups and the Linux kernel itself.
What's really Docker
Docker Engine?
Since it's based on LXC it does not include a separate Operating System (OS)
Docker container vs Virtual Machine
- what's better?
Here's a single Linux OS running several Docker containers - APP 1, APP2, APP3
Docker container vs Virtual Machine
- what's better?
Here's a single Linux OS running several VMs including - APP 1, APP2, APP3
Docker container vs Virtual Machine
- what's better?
Docker containers enable:
- Portable deployment across machines - you can transfer images quickly into other Docker-enable Linux hosts
- Versioning (more further in the presentation)
- Component reuse - using prebuilt images or creating base images and reusing them
- Shared libraries - using community build images from the official Docker Hub
- Read even more at https://docs.docker.com/engine/faq/#/how-do-containers-compare-to-virtual-machines
How to create a Docker container
# Dockerfile
# Read more about Dockerfile syntax
# at https://docs.docker.com/engine/reference/builder/
FROM docker/whalesay:latest
RUN apt -y update && apt install -y fortunes
CMD /usr/games/fortune -a | cowsay
docker build -t docker-whale .
1. Create a Dockerfile that describes what your container wants to have. File syntax:
3. Run a Docker container using the prebuilt Docker image
docker run docker-whale
2. Build a Docker image by using the Dockerfile
How to create a Docker container
Now a more "complex" container that communicates with another container.
Container 1: Sinatra Application
Container 2: Postgres DB
How to containerize your monolith and/or microservices using Docker
By Anton Antonov (syndbg)
How to containerize your monolith and/or microservices using Docker
- 341