Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Docker compose not updating images after change

I have a yml file for docker compose to create two containers and connect them. I made some changes to the code today(replaced a folder to be added in one of the docker files).Here's the yml file:

version: '3'
services:
  web:
    build: ./web
    ports:
     - "8000:8000"
    restart: always
    volumes:
     - web:/www

  nginx:
    build: ./nginx
    ports:
     - "80:80"
    restart: always
    links:
     - web
    volumes:
     - web:/www
volumes:
    web:

The change I made was to the dockerfile in ./web:

FROM python:3.6.4

RUN mkdir /www
WORKDIR /www
ADD . /www/
RUN pip install -r requirements.txt
EXPOSE 8000
CMD python /www/davidbien/manage.py migrate
CMD cd dockertest && gunicorn dockertest.wsgi:application -w 2 -b :8000

The change I made was to change the /davidbien/ folder name from dockertest folder.

I tried rebuilding images by running:

docker-compose build --no-cache

But this did not help. I also tried the same command without --no-cache. I also tried :

docker-compose up --force-recreate

After rebuilding but when I run the script I don't know why the old folder still appears(even though it's removed). What else can I do to clear the cache in docker-compose? I googled that but only got the above two commands. Thanks

like image 245
davidb Avatar asked Jan 20 '18 21:01

davidb


People also ask

Does docker compose update images?

Docker Compose has a built-in pull command that will pull updated versions of all the images in your stack.

How do I automatically update docker images?

By pushing a new Docker image to your repository, Watchtower will automatically trigger a chain of events to update your running container's base Docker image. When Watchtower detects a new push, it will pull the new base image, gracefully shutdown your running container, and start it back up.


1 Answers

I had the same issue and the quickest way I manage to solve this and get my containers updated is by changing their names.

So, I had a container named app and it's settings in app.docker. I renamed this to php and php.docker respectively. Running docker-composer up -d created the updated containers.

like image 166
Keith Mifsud Avatar answered Oct 13 '22 17:10

Keith Mifsud