I have installed the Docker extension in VS Code. I am creating a Python cookie-cutter repository that I will use as a template to create new feature repositories. Part of the template is a Dockerfile where I want to specify a Python image (e.g. python:3.10-slim
) but the image name will change based on the Python version used in the feature repository. To accommodate this, the Dockerfile in the cookie-cutter repository contains the line of code FROM python:{{cookiecutter.python_version}}-slim
. Then when I am building the feature repository, the cookie cutter builds the appropriate line in the real file (e.g. FROM python:3.10-slim
)
But when I include that line in the Dockerfile within the cookie-cutter
repository, I get the following linter warning
[{
"resource": "/c:/source_code/electroroute_code/python_cookiecutter/{{cookiecutter.app_name}}/Dockerfile",
"owner": "_generated_diagnostic_collection_name_#3",
"code": "26",
"severity": 8,
"message": "invalid reference format",
"source": "dockerfile-utils",
"startLineNumber": 3,
"startColumn": 13,
"endLineNumber": 3,
"endColumn": 49
}]
The linter warning disappears when I disable the Docker extension.
I want to include the Docker extension in VS Code. I also want to disable this linter warning for the cookie-cutter repository, without impacting the Docker linter warnings for the feature repositories.
I have tried adding the following code to the .vscode/settings.json
file in the repository but it made no difference.
{
"docker.languageserver.lintingRules": {
"26": "ignore"
}
}
I have also tried creating a hadolint.yaml
file at the root of the repository to ignore the problem rule but that made no difference. The hadolint.yaml
file contained
ignored:
- DL3006
Any help would be greatly appreciated.
Please try adding using the # dockerfile-utils: ignore
comment to ignore issues from dockerfile-utils
. This was introduced into the VS Code extension last year so this feature should be available to you.
# dockerfile-utils: ignore
FROM python:{{cookiecutter.python_version}}-slim
Hope it helps!