Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use COPY instead of ADD for files and folders #433

Closed
avelino opened this issue Sep 13, 2020 · 0 comments
Closed

Use COPY instead of ADD for files and folders #433

avelino opened this issue Sep 13, 2020 · 0 comments

Comments

@avelino
Copy link
Member

avelino commented Sep 13, 2020

Problematic code:

ADD ./cmd/prestd/prest.toml /app/prest.toml
ADD ./etc/entrypoint.sh /app/entrtpoint.sh

Correct code:

COPY ./cmd/prestd/prest.toml /app/prest.toml
COPY ./etc/entrypoint.sh /app/entrtpoint.sh

here: https://github.com/prest/prest/blob/d9d3ebc0d554e6fa8250630524c289303781bd90/Dockerfile#L11:L12

Rationale:

https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#add-or-copy

For other items (files, directories) that do not require ADD’s tar auto-extraction capability, you should always use COPY.

Rule also implemented in https://github.com/RedCoolBeans/dockerlint/blob/master/src/checks.coffee

Exceptions:

Consequently, the best use for ADD is local tar file auto-extraction into the image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant