Reputation: 7782
I am trying to build react app in docker, here is my Dockerfile:
FROM node as build-step
LABEL stage=build-step
RUN mkdir /app
WORKDIR /app
COPY package.json /app
RUN npm install
COPY . /app
RUN npm run build
FROM nginx
COPY --from=build-step /app/build /usr/share/nginx/html
Using this command:
docker build . --rm -t react-server-manual:0.1
This works, but it is creating a few other images that's useless, how do I delete them?
What am I missing?
Upvotes: 0
Views: 792
Reputation: 1
For more context on the --rm
flag/option:
There was indeed a --rm
option for the docker build
/docker image build
command, but that was before the buildx/build_kit addition.
In the docker's own (no buildx plugin), one can see the rm
option here, while on the buildx plugin, there's no rm
option, here.
Upvotes: 0
Reputation: 15248
Unfortunately this --rm
doesn't remove such intermediate images
You can run
docker build . -t react-server-manual:0.1 && \
docker image prune -f --filter label=stage=build-step
(or prune as separate command)
Upvotes: 3