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

187
Views
Update shared volume from data container

Hi guys i'm in this situation, i'd like to deploy the changes in my source code by rebuilding the data container which contains a COPY command for transfer the source in the volume. However when i rebuild the data image and re-run docker-compose i stuck with the old code and the only way to update everything is to remove the webroot volume and recreate it.

Where is the mistake??

server:
  build: ./docker/apache
  image: server:1.3.16
  restart: always
  links:
    - fpm
  ports:
    - 80:80 # HTTP
    - 443:443 # HTTPS
  volumes:
    - webroot:/var/www/html:ro

fpm:
  build: ./docker/php
  image: fpm:1.0
  restart: always
  links:
    - database
  volumes:
    - webroot:/var/www/html

data:
  build:
   context: .
   dockerfile: dataDockerFile
  image: smanapp/data:1.0.0
  volumes:
    - webroot:/var/www/html

volumes:
  webroot:
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

The named volume webroot is meant to persist data across container restart/rebuilds. The only time the data in the volume is updated from an image is when the volume is created, and the contents of the directory in the image are copied in.

It looks like you mean to use volumes_from which is how you get container to mount volumes defined on data. This is the original "data container" method of sharing data that volumes were designed to replace.

version: "2.1"

services:

  server:
    image: busybox
    volumes_from:
      - data
    command: ls -l /var/www/html

  fpm:
    image: busybox
    volumes_from:
      - data
    command: ls -l /var/www/html

  data:
    build: .
    image: dply/data
    volumes:
      - /var/www/html

Note that this has been replaced in version 3 of the compose file so you may need to stick with recreating the volume if you want to use newer features.

over 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!