Docker Community Forums

Share and learn in the Docker community.

Is there a difference between docker-compose.yml settings

In the compose file below I created two separate services db and db Alternate as an example. Does networks: have to be an array and image: a value. Where do I find the specs for each one of the services e.g. db? Thanks.

version: "3.9"

    build: ./proxy
      - frontend
    build: ./app
      - frontend
      - backend
    image: postgres
      - backend

  # Alternate Can these settings also work?
  # db:
  #   image: 
  #     - postgres
  #   networks: backend

    # Use a custom driver
    driver: custom-driver-1
    # Use a custom driver which takes special options
    driver: custom-driver-2
    foo: "1"
    bar: "2"

The value of Image is a single string, which can optionaly be surrounded by single or double quotes.

The value of networks can either be a sequence (~=yaml lingo fo arrays), which is the short syntax, or a map, which allows the long syntax. While the short syntax only allows to assign a service to one or more networks, the long syntax allows further configurations, like assigning an alias for the service in a particular network.

I assume you are refering to the docker compose reference and not the actualy db service you declared yourself. You can not make up what keys are available or what values they expect. You might want to take a closer look at the docker compose file reference as it explains and shows usuage examples and mentions in which docker compose file schema version configuration items are supported:

1 Like