Docker Community Forums

Share and learn in the Docker community.

Docker COPY not updating files when rebuilding container on cloud provider

I have a docker-compose-staging.yml file which I am using to define a PHP application. I have defined a data volume container (app) in which my application code lives, and is shared with other containers using volumes_from.

docker-compose-staging.yml:

version: '2'
services:
    nginx:
        build:
            context: ./
            dockerfile: docker/staging/nginx/Dockerfile
        ports:
            - 80:80
        links:
            - php
        volumes_from:
            - app

    php:
        build:
            context: ./
            dockerfile: docker/staging/php/Dockerfile
        expose:
            - 9000
        volumes_from:
            - app

    app:
        build:
            context: ./
            dockerfile: docker/staging/app/Dockerfile
        volumes:
            - /var/www/html
        entrypoint: /bin/bash

This particular docker-compose-staging.yml is used to deploy the application to a cloud provider (DigitalOcean), with my local docker-machine configured to use a cloud provider using the guide at docs.docker.com/machine/get-started-cloud, and the Dockerfile for the app container has COPY commands which copy over folders from the local directory to the volume defined in the config.

docker/staging/app/Dockerfile:

FROM php:7.1-fpm
COPY ./public /var/www/html/public
COPY ./code /var/www/html/code

This works when I first build and deploy the application. The code in my public and code directories are present and correct on the remote server. I deploy using the following command:

docker-compose -f docker-compose-staging.yml up -d

However, next I try adding a file to my local public directory, then run the following command to rebuild the updated code:

docker-compose -f docker-compose-staging.yml build app

The output from this rebuild suggests that the COPY commands were successful:

Building app
Step 1 : FROM php:7.1-fpm
 ---> 6ed35665f88f
Step 2 : COPY ./public /var/www/html/public
 ---> 4df40d48e6a5
Removing intermediate container 7c0fbbb7f8b6
Step 3 : COPY ./code /var/www/html/code
 ---> 643d8745a479
Removing intermediate container cfb4f1a4f208
Successfully built 643d8745a479

I then deploy using:

docker-compose -f docker-compose-staging.yml up -d

With the following output:

Recreating docker_app_1
Recreating docker_php_1
Recreating docker_nginx_1

However when I log into the remote containers, the file changes are not present.

I’m relatively new to Docker so I’m not sure if I’ve misunderstood any part of this process! Any guidance would be appreciated.