1

Is there some globally admitted coding conventions for docker-compose files? Below is a sample docker-compose.yml from a small project we have here:

version: 3
networks:
  net:
    driver: 'bridge'

services:
  app:
    build: .
    networks:
    - net
    ports:
    - 3000:3000
  redis:
    image: redis:alpine
    networks:
    - net
  client:
    image: "app/test_clients"
    deploy:
      replicas: '3'

The quoting is especially inconsistent. Sometimes quotes are used around text and numerical literals. Sometimes they aren't. Sometimes single quotes are used, sometimes double quotes are used instead. The various example in the official docker-compose documentation seems relatively inconsistent in that area too.

This is valid YAML. And YAML is very permissive about quoting and, as far as I know, quotes could simply be omitted in most of the cases. I know this is probably a matter of internal policy but I wonder if there are some commonly accepted "best practices" in that matter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.