mirror of https://github.com/docker/docs.git
Clearer purpose and contents for .dockerignore
I had to read the original paragraph a few times and search for docs on the file's purpose to understand what this step entailed. So here's another try at an explanation of what to do and why, with a hint about best practice.
This commit is contained in:
parent
ac62c90284
commit
b90deff361
|
@ -153,7 +153,13 @@ CMD ["./mvnw", "spring-boot:run"]
|
|||
|
||||
### Create a `.dockerignore` file
|
||||
|
||||
To use a file in the build context, the Dockerfile refers to the file specified in an instruction, for example, a `COPY` instruction. To increase the performance of the build, and to exclude files and directories, we recommend that you create a `.dockerignore` file to the context directory. To improve the context load time, add a `target` directory within the `.dockerignore` file.
|
||||
To increase the performance of the build, and as a general best practice, we recommend that you create a `.dockerignore` file in the same directory as the Dockerfile. For this tutorial, your `.dockerignore` file should contain just one line:
|
||||
|
||||
```
|
||||
target
|
||||
```
|
||||
|
||||
This line excludes the `target` directory, which contains output from Maven, from the Docker build context. The build context is what Docker commands like `RUN` refer to and it has to be created for every build, by packaging up any files not excluded by `.dockerignore`. There are many good reasons to carefully structure a `.dockerignore` file, but this one-line file is good enough for now.
|
||||
|
||||
## Build an image
|
||||
|
||||
|
|
Loading…
Reference in New Issue