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

Dockerfile Linter doesn't recognize directory destination in COPY command #4292

Open
SetTrend opened this issue Apr 28, 2024 · 5 comments
Open

Comments

@SetTrend
Copy link

SetTrend commented Apr 28, 2024

Synopsis

Although I correctly added a backslash to the destination of my COPY commands, the Dockerfile linter throws an error claiming that I didn't:

Dockerfile linter error

Current Situation

The Dockerfile linter erroneously throws an error about a missing a trailing backslash although it has been provided.

Desired Situation

  1. A trailing backslash should only be required for the destination path if the source is not a single file.
    (For paths containing spaces, the array syntax is mandatory.)
  2. A trailing backslash in the destination path portion of the command should correctly be recognized.
  3. The use of variables (ARG, ENV variables) should be correctly parsed and interpreted.

VS Code Docker Extension Version

v1.29.0



Dockerfile Example Using Variables

The same Dockerfile as above, this time using variables for destination:

Dockerfile example using variables

@rcjsuen
Copy link
Contributor

rcjsuen commented Apr 29, 2024

For the backslash case, it's the challenge of interpreting quotes. As a workaround, if you put double backslashes the issue should go away.

@SetTrend
Copy link
Author

SetTrend commented Apr 29, 2024

I'm not confident that your statement is correct.

In the first line of the Dockerfile there is a parser directive # escape=` . The Dockerfile reference claims that when using this directive, you don't need to escape backslashes.

@rcjsuen
Copy link
Contributor

rcjsuen commented Apr 29, 2024

I'm not confident that your statement is correct.

In the first line of the Dockerfile there is a parser directive # escape=`. The Dockerfile reference claims that when using this directive, you don't need to escape backslashes.

@SetTrend Thank you for pointing that out. You are correct that it does seem that the parser directive is not just for newlines at the end of a line in the file but also for content within the line. Sorry about that.

The escape character is used both to escape characters in a line, and to escape a newline.

@SetTrend
Copy link
Author

SetTrend commented Apr 30, 2024

Perhaps you may want to follow this discussion on the Dockerfile COPY syntax first before beginning to solve this issue:

/docker/docs/issues/19922: Dockerfile COPY instruction description is misleading

@rcjsuen
Copy link
Contributor

rcjsuen commented Apr 30, 2024

Perhaps you may want to follow this discussion on the Dockerfile COPY syntax first before beginning to solve this issue:

/docker/docs/issues/19922: Dockerfile COPY instruction description is misleading

Thanks for the pointer. This does sound vaguely familiar...

@dbreshears dbreshears added this to the 1.30.0 milestone May 8, 2024
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

4 participants