docs
docs copied to clipboard
Cache and volumes documentation improvements
As per the following PR "https://github.com/docker/docs/pull/20449" explaining that installing dependencies within the Dockerfile can be rolled back across volumes in development environments, it is interesting that you are also warned about dependency managers.
Description
For production environments, the current example is perfect. However, in development environments, we could have a new section explaining that using volumes would be sufficient instead of copying the content again with "COPY . .". Additionally, it is not necessary to run "npm run build" just to cache the layer, as this is not advantageous in development.
It is also recommended not to run package managers like npm, Composer, Maven, pip, etc., inside the image. Leave the installation to the CMD or ENTRYPOINT. This is important to ensure that the shared volume in development does not overwrite the files installed by the package manager.
FROM node
WORKDIR /app
COPY . . # Copy over all files in the current directory
RUN pip install -r requeriments.txt # Install dependencies
RUN python -m flask # RUN Flask
Reviews
- [ ] Technical review
- [ ] Editorial review
- [ ] Product review
Deploy Preview for docsdocker ready!
| Name | Link |
|---|---|
| Latest commit | 5b022d926f29bb9e8c65a8bb08e2a9ad83eddde3 |
| Latest deploy log | https://app.netlify.com/sites/docsdocker/deploys/669d3b6c96b66b0008d6e605 |
| Deploy Preview | https://deploy-preview-20450--docsdocker.netlify.app |
| Preview on mobile | Toggle QR Code...Use your smartphone camera to open QR code link. |
To edit notification comments on pull requests, go to your Netlify site configuration.
This observation is important, when I was studying the documentation, I had difficulties because in development environments the volumes overwrite the node_modules generated through Dockerfile.
I wrote a similar issue: https://github.com/docker/docs/pull/20449
Thanks for the pull request. We'd like to make our product docs better, but havenβt been able to review all the suggestions. As our docs have also diverged, we do not have the bandwidth to review and rebase old pull requests.
If the updates are still relevant, review our contribution guidelines and rebase your pull request against the latest version of the docs, then mark it as fresh with a /remove-lifecycle stale comment.
If not, this pull request will be closed in 30 days. This helps our maintainers focus on the active pull requests.
Prevent pull requests from auto-closing with a /lifecycle frozen comment.
/lifecycle stale