Byte Ebi's Logo

Byte Ebi 🍀

A Bit everyday A Byte every week

Docker Notes 3 - docker-compose

Introducing how to manage multiple containers using docker-compose

Ray

Series : Docker Notes (Part 3 of 3) View full series β†’

When it comes to managing multiple Docker containers that are related to each other, using plain Docker commands requires remembering the relationships between containers.
However, with docker-compose, managing multiple containers becomes straightforward through easy definition of multi-container services.

Introduction

  • Docker for Mac defaults to docker-compose.
  • A tool written in Python.
  • Defined by YAML.
  • Configuration file: docker-compose.yml.
  • Depends on the Docker version.

Official Documentation: docker-compose

Configuration File Structure

docker-compose.yml consists of two main parts:

  • version (must be a string).
  • services
    • key -> DNS name (hostname)

Example of docker-compose

Other Tools

docker-swarm

  • Considered as a counterpart to Kubernetes.
  • Convenient deployment (less preparation compared to Kubernetes).
  • High availability HA .
  • Cost-effective.

Components (Node)

  • Divided into two nodes:
    • Manager:
      • Assigns tasks to worker nodes.
      • Also acts as a worker node.
      • Controls the entire Docker Swarm deployment.
      • Primary control node.
      • If it fails, the entire Docker Swarm fails.
      • Can have multiple managers, but only one &$%^^#???
    • Worker:
      • Assigned tasks but does not actively assign tasks.
      • Unaware of other worker nodes.
  • Rolling updates can be performed at any time.
  • Under all nodes:
    • Service:
      • Represents a container.
      • Starting a service does not mean starting a container.
      • Can perform health checks on containers.
      • Services can start multiple containers (replicas).
    • Task:
      • Primarily initiated by the Service.
      • Represents commands executed within a Docker container.
      • Tasks execute on a node until completion.

Recent Posts

Categories

Tags