Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!