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:

  • Error: failed to checkpoint one or more containers
  • Looking for Moby Linux on AWS ssh username
  • Docker, mount volumes as readonly
  • Kubernetes restarting pods
  • Using private docker registry for GitLab CI
  • Access cephfs inside docker without mounting cephfs on host
  • 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

  • Problems setting up artifactory as a docker registry
  • How to start a python script after etcd is running in a single docker container?
  • How do I save kubectl logs to a file on my host machine?
  • Dockerfile: Docker build can't download packages: centos->yum, debian/ubuntu->apt-get behind intranet
  • How to fix docker-machine ip?
  • npm install fails in jenkins pipeline in docker
  • 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.