Docker does not create a new container when using docker-compose build

I’ve set up two windows container for ASP.NET and MSSQL server. On the first docker-compose build everything works as expected. Then after I’ve made some changes (because im testing stuff) to the custom dockerfile and run docker-compose build again it uses the old container again, not making any changes.

I assumed that when i did a build it created a new container. Am i misunderstanding how docker works?

This is the docker-compose.yml

version: '3'
services:
  db:
    image: microsoft/mssql-server-windows-developer

    environment:
      sa_password: "Password1234!"
      ACCEPT_EULA: "Y"

    ports:
      - "8003:1433"
    build:
      context: .
      dockerfile: mssql.dockerfile

  web:
    build:
      context: .
      dockerfile: web.dockerfile
    image: mcr.microsoft.com/dotnet/framework/aspnet:4.8
    #volumes:
    #  - .:C:/inetpub/wwwroot
    ports: 
      - "8080:80"
      - "8081:431"

This is the mssql.dockerfile

# escape=`

FROM microsoft/mssql-server-windows-developer

#set shell
SHELL ["powershell.exe", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]

#make temp folder
RUN mkdir C:\temp

#copy script to temp folder
COPY DownloadDatabase.ps1 C:\temp
COPY RestoreDatabase.ps1 C:\temp

#run script to retrieve production database
WORKDIR C:\temp

RUN .\DownloadDatabase.ps1 -sourcefile <url> -destinationfile <target>

CMD .\RestoreDatabase.ps1

It is very easy to tell if the image has been re-used because the mkdir C:\temp errors out saying the directory already exists.

I’ve already tried all the options on docker compose. no-cache, force-rm

I’ve solved the issue by calling docker-compose pull before docker-compose build

That way it properly uses the new dockerfile