Normally, dockerfiles all have the same name Dockerfile
and VS Code can recognize it. But, in some projects, dockerfiles are named like foo.docker
and bar.docker
. Vs Code cannot recognize them and treat them as plain text files.
Of course you can use Change language mode
by hand to fix it, but it's a bit annoying. How can we do it once and for all?
Open VS Code's settings page, and search files.associations
, press Add Item
. Then, input the key and value.
Key:
*.docker
Value:
dockerfile
If you prefer to edit json file directly, use this:
{
"files.associations": {
"*.docker": "dockerfile"
}
}