Sobes.tech
Senior

What is Docker Compose? How does Docker differ from a virtual machine?

sobes.tech AI

Answer from AI

Docker Compose is a tool for defining and running multi-container Docker applications. With the docker-compose.yml file, you can describe the configuration of services, networks, and volumes, and then bring up the entire infrastructure with a single command.

Differences between Docker and a virtual machine:

  • Isolation: Docker uses containers that isolate applications at the OS level, sharing the kernel, whereas a virtual machine emulates a full OS with its own kernel.
  • Resources: Containers are lighter and start faster because they do not require loading a separate OS.
  • Performance: Containers are closer to native performance, while virtual machines have virtualization overhead.
  • Size: Docker images are usually significantly smaller than virtual machine images.

Example docker-compose.yml:

version: '3'
services:
  web:
    image: nginx
    ports:
      - "80:80"
  db:
    image: postgres
    environment:
      POSTGRES_PASSWORD: example
What is Docker Compose? How does Docker differ from a… - sobes.tech