Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to force docker-compose to download a new image when using docker hub?

I have a docker-compose.yml file which takes the image svka4019/notes2:latest from the docker hub. However, if I change the image build it and push it, when I run docker-compose it just uses the one it has already downloaded before. Here is the docker-compose.yml:

springboot-docker-compose-app-container: 
    image: svka4019/notes2:latest
    ports:
      - "80:5001"
    depends_on:
    - friendservice
    networks:
    - mynet
    container_name: base_notes
  friendservice:
    build: ./Pirmas
    command: python app.py
    ports:
    - 5000:5000
    container_name: friend
    networks:
    - mynet
    
networks:
    mynet:

And the command I use for building and running: docker-compose up --build -d. For updating the image in docker-hub I use:

docker build -t svka4019/notes2
docker push svka4019/notes2

If I use methods as no-cache it just rebuilds friendService container and skips the base one.

like image 921
Svajunas Kavaliauskas Avatar asked May 07 '19 22:05

Svajunas Kavaliauskas


1 Answers

As @DazWilkin pointed out in the comments, using latest tag should be used carefully. Not only can it introduce bugs in your app if latest comes with BC breaks, but it also doesn't indicate that a new update must be performed on your machine if you already have an image 'latest'.

In your case, what you have to do should you want to keep using latest, is to simply call:

docker-compose pull

In case you are building your own image, then you must do:

docker-compose build --pull

The latter will tell docker-compose to first pull the base image before building your custom image.

like image 68
Toni Van de Voorde Avatar answered Oct 18 '22 21:10

Toni Van de Voorde