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
Docker stack deploy rolling updates volume issue

I'm running docker for a production PHP-FPM/Nginx application, I want to use docker-stack.yml and deploy to a swarm cluster. Here's my file:

version: "3"
services:

app:
  image: <MYREGISTRY>/app
volumes:
   - app-data:/var/www/app
deploy:
  mode: global

php:
  image: <MYREGISTRY>/php
volumes:
   - app-data:/var/www/app
deploy:
  replicas: 2

nginx:
  image: <MYREGISTRY>/nginx
    depends_on:
      - php
  volumes:
    - app-data:/var/www/app
  deploy:
    replicas: 2
  ports:
    - "80:80"

volumes:
 app-data:

My code is in app container with image from my registry.

I want to update my code with docker service update --image <MYREGISTRY>/app:latest but it's not working the code is not changed. I guess it uses the local volume app-data instead.

Is it normal that the new container data doesn't override volume data?

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I was having the same issue that I have app and nginx containers sharing the same volume. My current solution having a deploy script which runs

docker service update --mount-add mount service

for app and nginx after docker stack deploy. It will force to update the volume for app and nginx containers.

about 4 years ago · Santiago Trujillo Relatório

0

Yes, this is the expected behavior. Named volumes are only initialized to the image contents when they are empty (the default state when first created). Updating the volume any time after that point would risk data loss from overwriting or deleting volume data that you explicitly asked to be preserved.

If you need the files to be updated with every new image, then perhaps they shouldn't be in a volume? If you do need these inside a volume, then you may need to create a procedure to update the volumes from the image, e.g. if this were a docker run, you could do:

docker run -v app-data:/target --rm <your_registry>/app cp -a /var/www/app/. /target/.

Otherwise, you can delete the volume, or simply remove all files from the volume, and restart your stack to populate it again.

about 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