In our Jenkins agents we are running about several (around 20) tests whose setup involves running docker-compose up for a \"big\" number of services/containers
docker-compose down
Running docker-compose down and then running docker-compose up --build may work. I am working on vscode and when I encountered a similar problem while building docker, this solution worked for me.
Before performing above mentioned command its better you refer to what is the purpose of docker-compose down