Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment Variable created in postCreateCommand of devcontainer.json not persisted #7016

Closed
leopk-code-sf opened this issue Aug 3, 2022 · 5 comments
Labels
containers Issue in vscode-remote containers feature-request Request for new features or functionality

Comments

@leopk-code-sf
Copy link

  • VSCode Version: Version: 1.69.2 (Universal)
  • Local OS Version: MacOS Monterey
  • Remote Extension/Connection Type: Containers

I am trying to assign an environment variable that takes the path of the container-host mounts to pass them on into a docker-compute that will be launched from the development container (using the docker-from-docker functionality). I attempt this using a postCreateCommand in the devcontainer.json:

{
  ...
  "postCreateCommand": "export MOUNT_PATH=$(docker inspect $(hostname) | jq '.[0].HostConfig.Mounts' | jq '.[0].Source')"
  ...
}

However, I am not able to access the environment variable once the container has finished launching. $ echo $MOUNT_PATH returns nothing and it also does not show up when running $ printenv. The only way I can achieve this is to once again run the postCreateCommand manually, once the container is running.

Note: The command itself seems to be working, as "postCreateCommand": "echo MOUNT_PATH=$(docker inspect $(hostname) | jq '.[0].HostConfig.Mounts' | jq '.[0].Source')" does print the correct value to the command line during the container launch process.

@github-actions github-actions bot added the containers Issue in vscode-remote containers label Aug 3, 2022
@aaronpowell
Copy link

The same issue can be observed with postStartCommand.

@chrmarti
Copy link
Contributor

These commands are run in a separate shell. Marking as feature request.

@chrmarti chrmarti added the feature-request Request for new features or functionality label Sep 20, 2022
@VSCodeTriageBot VSCodeTriageBot added this to the Backlog Candidates milestone Sep 20, 2022
@VSCodeTriageBot
Copy link
Collaborator

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!

@VSCodeTriageBot
Copy link
Collaborator

This feature request has not yet received the 10 community upvotes it takes to make to our backlog. 10 days to go. To learn more about how we handle feature requests, please see our documentation.

Happy Coding

@VSCodeTriageBot
Copy link
Collaborator

🙁 In the last 60 days, this feature request has received less than 10 community upvotes and we closed it. Still a big Thank You to you for taking the time to create this issue! To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

@VSCodeTriageBot VSCodeTriageBot closed this as not planned Won't fix, can't repro, duplicate, stale Nov 21, 2022
@github-actions github-actions bot locked and limited conversation to collaborators Jan 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
containers Issue in vscode-remote containers feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

4 participants