I want to create a multistage build process whereas each of the docker files are nested inside their own directories locally with their corresponding dependencies that are ADDed in for each Docker file. Is there a way to import a Docker file from a different directory locally whereas I am able to import it with Docker's FROM
command, to create several stages in a build?
If not, would I be able to ADD
the other staged Docker file's into the current Docker file and then use FROM
inside the docker container, deleting it after it is added and used in FROM
?
Maybe I am thinking about multistage builds the wrong way.
Or can I simply run FROM {path/to/docker/locally}
? This is not working for me.
Is there a way to import a Docker file from a different directory locally whereas I am able to import it with Docker's FROM command, to create several stages in a build?
No. The FROM
instruction is used to import pre-built images only, it can not be used to import a Dockerfile.
If not, would I be able to ADD the other staged Docker file's into the current Docker file?
No. The ADD
instruction can only copy files inside the build context (which usually is the current working directory) to containers. You cannot ADD ../something /something
.
Or can I simply run FROM {path/to/docker/locally}?
No. But one way that is gonna work for you is, to build the other image first, say its name is first-image:latest
, then you can use the COPY
instruction to copy files from that image:
COPY --from=first-image:latest /some/file /some/file