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:
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.