Writing a docker-compose file

The Docker Compose file is a simple YAML-format file that contains instructions about an isolated system with links to multiple containers. We can also define the environment of each individual container. It is able to start or stop a composite of services with one command. A typical docker-compose.yml file looks like the following:

version: "2" 
services: 
  eureka: 
    image: doj/eureka-server 
    ports: 
      - "8080:8761" 
  account: 
    image: doj/account-service 
    ports: 
      - "8181:6060" 
    links: 
      - eureka 
  customer: 
    image: doj/customer-service 
    ports: 
      - "8282:6060" 
    links: 
      - eureka 
      - account

As you can see in the preceding docker-compose.yml file, it is very easy and has a simple yml syntax. Let's take a close look and what the file means: ...

Get Mastering Spring Boot 2.0 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.