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:

  • Does anyone know a docker image that contains The MySQL Test Framework, Version 2.0?
  • Using Docker in development for Java EE applications
  • “The output of `ssh-add -l` doesn't contain 'RSA'. Start the agent, add your keys?” in Docker
  • Running Docker Image
  • Docker .Net Core app on Ubuntu not opening in localhost:8000
  • Issue with docker compose: container command not found
  • 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

  • Checpoint/restore feature not working in Docker
  • Creating HazelCast cluster running on multiple docker containers
  • nginx + PHP-FPM: Doing away with fastcgi params
  • Docker MEAN stack which FROM to use?
  • When I start my app with PM2 + Docker, just run and exit
  • Not able to communicate with server on https when launched from marathon and 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.