In a multistage Docker build, should the WORKDIR be deleted?
When creating an image using a Dockerfile, docker layers are created for each step. The description of layers can be found on the official docker page.
Accordingly, when using Multistage to create an image, it introduces a new build step that can be named using an alias in the FROM statement, and all layers except the image layer created via the last FROM statement are deleted.
After build your image, check if the layer that contains WORKDIR whether exists or not using docker image inspect. I think you probably know the unique layer value for each step.
You can see the image consists with which layers.
e.g.,
$docker image inspect [OPTIONS] 464503b73bfe # IMAGE
[
    {
        &quot;Id&quot;: &quot;sha256:464bf1...46c&quot;,
        ...

        &quot;RootFS&quot;: {
            &quot;Type&quot;: &quot;layers&quot;,
            &quot;Layers&quot;: [
                &quot;sha256:26711...8fcf&quot;,
                &quot;sha256:6c5a51...56e0&quot;
            ]
        },
        ...