Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

162
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda