'Can't use an env file with vscode devcontainer: no such file or directory

I followed this short official video to try using an environment file in my devcontainer.json file. I have the same folder architecture than a the video, and my devcontainer.json looks like:

    "name": "myproject",
    "runArgs": [
        "--env-file",
        ".devcontainer/devcontainer.env"
    ],
    "build": {
        "dockerfile": "Dockerfile",
        "context": "..",
        "args": {}
    },

But I keep getting this error: docker: open .devcontainer/devcontainer.env: no such file or directory. when I run the rebuild container or rebuild container without cache.

But the file does exist. I can verify it by running ls .devcontainer/devcontainer.env in my recovery container.

I even versioned the devcontainer.env file and ran Clone Repository in container volume again. Still the same error.

Any idea on what's going on?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source