Closed jamiekt closed 1 year ago
Another use case that has popped up up today...
As you can see in devcontainer.json above we mount the ~/.aws
directory:
"source=${localEnv:HOME}/.aws,target=/root/.aws,type=bind,consistency=cached",
this is so that people can continue to interact with AWS via the aws
cli tool without having to to re-authenticate.
There are many ways to modify behaviour of aws
cli and one such way is to set environment variable $AWS_DEFAULT_PROFILE
. I set this on my host machine and it is very useful and I'd like to do the same in the container like so:
"containerEnv": {
"AWS_DEFAULT_PROFILE": "${localEnv:AWS_DEFAULT_PROFILE}"
}
however that shouldn't be the case for everyone that uses the devcontainer because their ways-of-working may be different. In this case I'd like there be an option for each user of the devcontainer to specify their own env vars that they'd like to use inside the container.
This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 10 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.
Happy Coding!
Some of what you want to do can be achieved by configuring a dotfiles repository in your user settings. E.g., if the dotfiles repository creates a ~/.gitconfig
, the Dev Containers extension will not copy the local ~/.gitconfig
to the dev container. A dotfiles install script can also add aliases and environment variables to ~/.bashrc
.
There is documentation on using dotfiles repositories with Dev Containers here: https://code.visualstudio.com/docs/devcontainers/containers#_personalizing-with-dotfile-repositories. HTH
Thank you @chrmarti , that definitely looks very promising indeed. I'll check it out.
ok, this seems to work great. I can pretty much do everything I need to using install.sh. Thank you @chrmarti
I blogged about using the dotfiles capability at https://medium.com/@jamiekt/vscode-devcontainer-with-zsh-oh-my-zsh-and-agnoster-theme-8adf884ad9f6
My team are using devcontainers in a repo that many of us use. We put a lot into the devcontainer, in fact here is our .devcontainer.json which I'm happy to share:
and here is the Dockerfile
The
postCreateCommand
calls a script postCreateCommand.sh that adds some aliases to .bashrc:Here's the problem. Some people want/need to make customisations that are specific to them. Some examples:
(read https://thoughtbot.com/blog/better-commit-messages-with-a-gitmessage-template to understand why)
~/.gitconfig automatically gets mounted in into the devcontainer as I'm sure you know, but of course there is no such file inside the devcontainer. This means every time I issue
git commit -a
I get an error telling me that .gitmessage doesn't exist. My workaround is to issuegit commit -am dummy && git commit --amend
which works but is cumbersome.Some people may want to create aliases that others do not. We could put them in postCreateCommand.sh as mentioned above but that means that file will eventually get littered with different people's aliases.
People may want extensions or features that others do not
I feel there should be better ways of solving these problem. I'd like to see support for user-specific config for devcontainers. For example, to solve the .gitmessage problem I could define a mount that only gets mounted for me. To solve aliases problem I could define a
postCreateCommand
that is only run for me.I suggest these could be accomplished by allowing us to define ./.vscode/userdevcontainer.json that might look something like this:
./.vscode/userdevcontainer.json would of course not get committed to source control, therefore allowing each user to specify their own customisations. This is just an idea, I suspect other folks could come up with other, better, ways of achieving this.
Bottom-line, I'd like there to be a way to specify user specific features, mounts, extensions and settings for devcontainers.