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

Set REMOTE_CONTAINERS=true environment variable #3517

Closed
felipecrs opened this issue Aug 14, 2020 · 17 comments
Closed

Set REMOTE_CONTAINERS=true environment variable #3517

felipecrs opened this issue Aug 14, 2020 · 17 comments
Assignees
Labels
containers Issue in vscode-remote containers feature-request Request for new features or functionality verification-needed Verification of issue is requested verified Verification succeeded

Comments

@felipecrs
Copy link

felipecrs commented Aug 14, 2020

This would be good, so scripts can get to know if they're running from a devcontainer on Remote - Containers or not. VS Codespaces have the CODESPACES by the way.

So far, I have to do:

function is_devcontainer() {
  if [ -n "${REMOTE_CONTAINERS_IPC+x}" ] || [ -n "${REMOTE_CONTAINERS_SOCKETS+x}" ] || [ -n "${VSCODE_REMOTE_CONTAINERS_SESSION+x}" ]; then
    return 0
  else
    return 1
  fi
}

Because the referenced variables are not set all the time.

@Chuxel
Copy link
Member

Chuxel commented Aug 14, 2020

Moving this feature request to the correct repo.

@Chuxel Chuxel transferred this issue from microsoft/vscode-dev-containers Aug 14, 2020
@Chuxel Chuxel added feature-request Request for new features or functionality containers Issue in vscode-remote containers labels Aug 14, 2020
@felipecrs
Copy link
Author

felipecrs commented Aug 14, 2020

Oh, my bad.

It does not show up on vscode-dev-containers yet though, should I close this one and create it there?

@Chuxel
Copy link
Member

Chuxel commented Aug 15, 2020

@felipecassiors Nope - I transferred it. The link works from both places when that happens, it's just offically in the vscode-remote-release repo now. 😄

@chrmarti
Copy link
Contributor

@felipecassiors You could add this to your devcontainer.json yourself:

	"remoteEnv": {
		"DEVCONTAINER": "true"
	}

That would cover Remote-Containers and Codespaces. (@Chuxel is there a list of devcontainer.json properties supported by Codespaces?)

@Chuxel
Copy link
Member

Chuxel commented Aug 17, 2020

@chrmarti Yes, this would work fine, but the general request is to have a common way to do it. We could coordinate to get that added. The other one I think may be good to add is LOCAL_WORKSPACE_PATH given that is needed for bind mounting in docker-from-docker. The example does the above to work around that, but it would be reasonable to just have it there.

@felipecrs
Copy link
Author

@felipecassiors You could add this to your devcontainer.json yourself:

	"remoteEnv": {
		"DEVCONTAINER": "true"
	}

That would cover Remote-Containers and Codespaces.

I see, but it would just cover the devcontainers I maintain. I need such a variable because of my dotfiles, since I perform some installation steps which are specific for devcontainer or codespaces.

@chrmarti
Copy link
Contributor

Got it. Would it make sense to call it REMOTE_CONTAINERS? Codespaces is running a devcontainer too. We could also make it DEVCONTAINER for both Codespaces and Remote-Containers (and maybe have all 3 to be clear?).

@felipecrs
Copy link
Author

Got it. Would it make sense to call it REMOTE_CONTAINERS? Codespaces is running a devcontainer too. We could also make it DEVCONTAINER for both Codespaces and Remote-Containers (and maybe have all 3 to be clear?).

It makes sense, and I believe the best is to have all the 3 as you said. :-)

@chrmarti
Copy link
Contributor

Setting REMOTE_CONTAINERS=true. Please open additional requests for additional variables.

@felipecrs
Copy link
Author

felipecrs commented Sep 10, 2020

@chrmarti thank you so much. So there is no DEVCONTAINER=true as you suggested before?

felipecrs added a commit to felipecrs/dotfiles that referenced this issue Sep 10, 2020
@chrmarti
Copy link
Contributor

Not right now, we need to coordinate with Codespaces to make sure they introduce that too (going by our earlier discussion). Please open a new issue if you want to see that implemented too.

@felipecrs
Copy link
Author

Not right now, we need to coordinate with Codespaces to make sure they introduce that too (going by our earlier discussion). Please open a new issue if you want to see that implemented too.

Alright. It's ok, this already fits my purpose.

@felipecrs felipecrs changed the title Set DEVCONTAINER=true environment variable Set REMOTE_CONTAINERS=true environment variable Sep 11, 2020
@felipecrs
Copy link
Author

@chrmarti I just tested here, and the variable does not seem to be set when the dotfiles installation happens. It's only available after. Therefore, I still need to rely on VSCODE_REMOTE_CONTAINERS_SESSION.

Note: CODESPACES is set on GitHub Codespaces during the dotfiles installation.

@chrmarti
Copy link
Contributor

@felipecrs That should be fixed in the latest (0.143.0) could you verify? Thanks.

@chrmarti chrmarti added the verification-needed Verification of issue is requested label Sep 29, 2020
@felipecrs
Copy link
Author

@chrmarti Verified!

image

I was not able to install v0.143.0 on VSCode stable though, so I installed in the insiders version. Is that expected?

@chrmarti chrmarti added the verified Verification succeeded label Sep 29, 2020
@chrmarti
Copy link
Contributor

@felipecrs Thanks! Yes, that version is only available for VS Code Insiders and then for VS Code 1.50 when that is released.

@felipecrs
Copy link
Author

Awesome, thanks.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 25, 2020
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 verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

3 participants