Docker Compose not updating content

I have some containers running with docker compose but I just can’t find a way to properly update my containers without having to remove it and create it again. I have a Python app and I can successfully deploy code changes and those get applied, but if I add files like css, js or images those don’t get to the container.

I have tried with this command, even though in the console it logs the messages as expected (rebuild it with no cache) I had no no success:

  • Docker on OSX: How to start boot2docker in one shell and use it in another
  • OpenJDK 1.8.0 in Docker container has different timezone than /etc/timezone and from the host
  • Relationship Between a Deis Cluster and Scale command?
  • no internet inside docker-compose service
  • Installing phantomjs with node in docker
  • No docker-quickstart found on mac
  • docker-compose build --no-cache web && docker-compose up -d

    The only command that works for me is to remove it like this:

    docker stop $(docker ps -a -q) && docker rm $(docker ps -a -q) && docker rmi $(docker images -a -q)

    And then build and deploy:

    docker-compose build && docker-compose up -d

    Here’s my docker-compose.yml:

      restart: always
      build: ./web
        - "8000"
        - postgres:postgres
        - redis
        - /usr/src/app/donare/static
      env_file: .env
      command: /usr/local/bin/gunicorn -w 2 -b :8000 --limit-request-line 16384
      restart: always
      build: ./nginx/
        - "80:80"
        - /www/static
        - web
        - web:web
      restart: always
      image: postgres:latest
        - /var/lib/postgresql
      command: "true"
      restart: always
      build: .
      dockerfile: dockerfile-postgres
        - data
        - "5432:5432"
      image: redis
      build: ./web
      command: celery worker --app=donare.tasks.tasks
        - .:/code
        - postgres
        - redis

  • Kubernetes, Java and Grafana - How to display only the running containers?
  • REST API container create and port bindings
  • How to run Karma tests from docker container?
  • Scope of the 'read-only' flag when mounting a volume in Docker
  • Microservices and Dockerfile and docker-compose.yml
  • Enable Postgis extension Postgres in Dockerfile
  • One Solution collect form web for “Docker Compose not updating content”

    Your Docker Compose file shows that you have a named volume in the web container. Is /usr/src/app/donare/static where your css, js, and images are supposed to come from on your Docker host? If so, perhaps you meant to mount /usr/src/app/donare/static into your container, not create a volume with that name? Or, if the css, js, and images are built into your image, then you should probably just remove that named volume.

    Assuming your css, js, and images are at the path /usr/src/app/donare/static in the container, then what’s happening is that because you have a named volume there, the first time you run the web service, a volume is being created and initialized with the contents at that path. Every time you do your build and up, that same initial volume is being mounted at the path with your old files. When you stop and rm, the volume is implicitly being deleted too, causing it to be recreated and initialized with fresh files.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.