How to fix problem with full image recreation using docker-compose?
I use maven and docker.
Command I use to build my services:
$ mvn package
To speed up the building process I skip unit tests with maven:
$ mvn package -Dmaven.test.skip=true
Ofcourse I remove entire target direcotry before I run
After I run
mvn package for all services, I run
docker-compose up which normally works ok. Until today.
After I run
docker-compose up I get an error:
[root@localhost]# docker-compose up Pulling auth-service (auth-service:3.1.1)... ERROR: The image for the service you're trying to recreate has been removed. If you continue, volume data could be lost. Consider backing up your data before continuing. Continue with the new image? [yN]^C Gracefully stopping... (press Ctrl+C again to force) [root@localhost]#
Anyone have idea how to fix this problem?
I found solution.
On each service:
1. Remove entire target directory.
mvn clean install
And I run docker docker-compose up and everything worked like a charm.
So yes, DO NOT USE maven package for your own sake :D
My problem was that I used maven pakcage instead of maven install.
Maven package - will build our jar + put it into target dir, nothing more and nothing less.
And we need our jar in .m2 repository on our computer to allow docker to get this jar from this repository when docker-compose builds images.
Read here the difference between maven package and maven install: