Languages

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

5 points
Asked by:
Root-ssh
7587

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)
[root@localhost]#

Anyone haveĀ idea how to fix this problem?

1 answers
2 points
Answered by:
Root-ssh
7587

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
Hey šŸ‘‹
Would you like to know what we do?
  • Dirask is online IT community for professionals and hobbyist to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.