docker-compose up problem - ERROR: The image for the service you're trying to recreate has been removed.

5 points
Asked by:

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 maven package.

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)

Anyone have idea how to fix this problem?

1 answer
2 points
Answered by:

I found solution.

On each service:

1. Remove entire target directory.

2. Run:

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:

Maven difference between package and install

0 comments Add comment
Native Advertising
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂