Docker
Раздел про Docker для бэкендера простыми словами: контейнеры и образы, Dockerfile для Spring Boot, multi-stage сборка, запуск контейнеров, тома и сети, Docker Compose, JVM в контейнере, безопасные образы и реестры.
A from-scratch section on Docker for backend developers: what containers and images are, how to package a Spring Boot application, how to shrink an image, how to bring up an environment of several services with Docker Compose, how to not lose data, and how to avoid the pitfalls of JVM memory. Best read in order.
- What Docker and containers are — We break down what a container and an image are, how Docker differs from a virtual machine, and why every backend developer needs this.
- Images, layers and the Dockerfile: how Docker packages an application — We break down what a Docker image is, which layers it consists of, and how to write a Dockerfile — using a Spring Boot application as an example, with an explanation of every instruction.
- A Dockerfile for Spring Boot: building the image the right way — How to write a Dockerfile for a Spring Boot application: a base JRE image, caching dependencies, passing profiles, layered jars, and the typical mistakes in containerization.
- Multi-stage builds and Docker layer caching — How to shrink a Spring Boot application image with a multi-stage build, instruction ordering, and layer caching — smaller size, faster CI.
- Running containers: docker run and the lifecycle — How to start a container, forward ports and environment variables, view logs, and get a shell inside — we break down docker run and the core management commands.
- Volumes and data in Docker: how to not lose your database when a container restarts — We break down why data in a container disappears when it is removed, and how to use volumes and bind mounts to keep it across restarts.
- Docker networking: how containers talk to each other — We break down how Docker isolates the network environment of containers, how to link several containers, and why localhost does not work here.
- Docker Compose: bring up the whole environment with one command — We break down Docker Compose from scratch: the structure of docker-compose.yml, linking services by name, healthchecks, dependencies, and an example with Spring Boot and Postgres.
- The JVM in a container: memory and cores — Why the JVM used to be "blind" to container limits, how to fix the memory and core settings, what OOMKilled is, and how to avoid it.
- Small and secure Docker images — How to shrink an image, keep secrets out of the layers, run the application as an unprivileged user, and scan the image for vulnerabilities.
- Image registries and building in CI — What an image registry is, how to publish and pull images, choose tags, and automate builds in CI — from docker push to a finished pipeline.