Extend service in docker-compose 3

This is very easy with YAML: version: “3” services: myservice: &myservice build: context: ./myservice command: ./something environment: &myservice_environment VAR1: “val1” VAR2: “val2” VAR3: “val3” myotherservice: <<: *myservice environment: <<: *myservice_environment VAR1: “val1-bis” See the doc regarding extension-fields

What is the equivalent of –add-host=host.docker.internal:host-gateway in a Compose file

The actual Docker Compose equivalent is achieved by appending the same string to the extra_hosts parameters (#Doc) as: version: ‘3.9’ services: postgres: image: postgres:14.1-bullseye environment: POSTGRES_PASSWORD: **** ports: – “5433:5432” extra_hosts: – “host.docker.internal:host-gateway” You can see it has been successfully mapped to the IP of the docker0 interface, here 172.17.0.1, from inside your container, e.g.: …

Read more