Salaah Amin
Salaah Amin

Reputation: 452

Docker compose up not using latest build even after a rebuild

I'm having a weird issue that's just started yesterday. Generally, I have a simple workflow such that whenever I have a new update, I would build the new containers, and restart docker.

So: bash docker-compose build <container> I then do docker-compose down; docker-compose up. And that uses the latest build.

But, for some reason, it keeps using the old build.

Within my Dockerfile, I have two these two lines:

COPY . .
RUN npm run build

What's really throwing me off is that in the stdout I can see that it is writing the new files and so using the latest version of the code (I know this because there are new files that didn't exist before and they're being logged in the stdout).

But, once it's built, and I go into the container, I can see that it's using the old version of the code.

So, to me it feels like, it's building correctly, just using the incorrect version.

I figured something buggy must have happened, and I literally deleted all containers, pruned the volumes, restarted ubuntu and tried again. And it worked!

Except, the issues started all over again and I can't seem to figure out what is going on.

Help?

EDIT: I should mention that I've tried docker-compose up --build, I've tried the force create and no cache flags. Stil no luck.

Upvotes: 2

Views: 4435

Answers (1)

Salaah Amin
Salaah Amin

Reputation: 452

I found the issue was related to the volume. Because I had now created a volume where two different containers were sharing the code, rather than using new code, it was always using the same code.

So to fix this, all that was needed was a -v on docker-compose down (docker-compose down -v).

This deleted all volumes and that resolved the issue.

Upvotes: 3

Related Questions