Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

161
Visualizações
Intentionally removing volumes in override docker-compose files

For production deployment, I don't want shared volumes. So, I have an override file but this does not remove the volumes.

Is there a way to remove shared volumes in an override file? I'd like to avoid having an override just for development, because that seems clunky to use.

This is my docker-compose.yml:

version: '2'
# other services defined here
services:
  web:
    build:
      context: .
    # other configuration
    volumes:
      - .:${APP_DIR}

And my docker-compose.prod.yml:

version: '2'
services:
  web:
    volumes: []
    restart: always
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I'm assuming you want to use docker-compose up to start the development version, and have a second config file to extend it for production.

If you want to make sure to override volumes completely, use a third config file, docker-compose.override.yml. Put all your volume definitions for development in there.

docker-compose up extends the base config with this file by default. But when you do something like docker-compose -f docker-compose.yml -f production.yml, the docker-compose.override.yml file won't be loaded, and you'll get only the volumes from the production file.

over 4 years ago · Santiago Trujillo Relatório

0

When merging a list entry in docker-compose, it adds new maps but doesn't remove existing volume mappings.

You can implement this by either making dev have the override file, or up to version 2.1 you can extend a common docker file rather than applying overrides which lets to devs point to a single file.

This could be your docker-compose.yml:

version: '2'
# other services defined here
services:
  web:
    extends:
      file: docker-compose.prod.yml
      service: web
    build:
      context: .
    restart: no
    volumes:
      - .:${APP_DIR}

And your docker-compose.prod.yml would contain all the common configuration and prod settings:

version: '2'
services:
  web:
    # other configuration
    restart: always
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda