Conversation
To persist the value into running containers. Fixes scicloj#29.
|
I still now too little about this. |
Hi @behrica apologies for the delayed reply. I don't know what you mean by "host variable"? Is there any use case or scenario where the username in the container needs to be something other than "vscode"? Regarding ARG vs ENV, this article explains the difference: https://www.docker.com/blog/docker-best-practices-using-arg-and-env-in-your-dockerfiles/ ARG: "The ARG instruction allows you to define variables that will be accessible during the build stage but not available after the image is built." ENV: "Unlike ARG, the ENV command allows you to define a variable that can be accessed both at build time and run time." This would imply that changing from ARG to ENV will not break anything, since ENV is available in both contexts. It also implies that USERNAME is needed at run time when the container starts. However, without further investigation I can't explain why (build-time only) ARG is sufficient for the "new dev container" case but not sufficient for the "clone repository in container volume" case. Suggestion: if ENV is observed to work for USERNAME in both cases anyway, that is a sufficient test result, and so this PR could be merged? Btw, some context:
|
In some scenarios I have used devcontainer with other usernames, like my real username on the host. I am not sure, if this needs to be supported by a devcontainer. |
|
so I am not sure, if this PR fixes a still existing problem. (and if it is the right way to solve) Could you please describe again in #35 "your scenario" and the "issue you have" with the latest template version (if still present) |
Hi @behrica, apologies for the delayed reply. I hit this problem again yesterday so I will describe again here the steps to reproduce, the expected result and the actual result: Steps:
Expected: Project is cloned successfully and basecloj container starts successfully with no errors. Calva extension is available and works, clj command is available and works. Actual: Container doesn't start successfully, instead it fails with an error message due to Instead, I have to then
Then, the container is able to start successfully. As you can imagine, it's frustrating that this error is being hit every time a developer needs to work on a different project locally. This error will block anyone trying to develop on any Clojure project from GitHub that doesn't already have a By comparison, the equivalent "dev containers: clone repository in container volume" built-in use-case and same steps for projects in other languages works fine. So it seems reasonable that we should expect this scenario to work for Clojure projects. I hope this makes sense now? Thanks Alex. |
|
I never use 'dev containers: clone repository in container volume', so that's why I don't see the error. I always do "git clone ..." and open the folder |
|
I executed the steps sas you said above, but dont get any error. |
|
Hi @behrica apologies for the delayed reply, I found some time to look at this again in more detail. The host OS where I see the error is Windows. I believe this is the problematic line in devcontainer.json: "USERNAME": "${localEnv:USER:vscode}" I believe there are two issues:
So as a result, on Windows hosts USERNAME will be empty when the Docker build runs and the groupadd command in the Dockerfile will fail. My suggested fix would be to hard-code the user name ("vscode" for example) in all the relevant places, devcontainer.json and Dockerfile. It would lose the matching user name for new containers, but I hope that wouldn't be a problem? If you're agreeable, I'd be happy to close this PR and make a new one. It would prevent the error for anyone who is trying to use the template from Windows. Thanks 🙏 |
To persist the value into running containers.
Fixes #29.