docs icon indicating copy to clipboard operation
docs copied to clipboard

Cache and volumes documentation improvements

Open Luan1Schons opened this issue 1 year ago β€’ 3 comments

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

Luan1Schons avatar Jul 21 '24 16:07 Luan1Schons

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...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

netlify[bot] avatar Jul 21 '24 16:07 netlify[bot]

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

WillRy avatar Jul 21 '24 16:07 WillRy

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

docker-robot[bot] avatar Oct 19 '24 01:10 docker-robot[bot]