CODESPACES environment variable is not set when using docker-compose

Hi,

When building containers, the CODESPACES environment variable is only set for the main container specified as “service” in .devcontainer.json
All other containers (when using docker-compose) do not have this variable set.

This makes it hard to differentiate between local and Codespace builds.

Thanks for reporting this! We’re working to expose the CODESPACES environment variable more broadly, and so I’ll make sure that we’re accounting for this use case as well. Stay tuned!

Hi @lostintangent,

Any workaround to be able to detect a codespace today? I want to set a variable in a Dockerfile (not the main service) based on the container running inside a codespace.
I’m using docker-compose to initialize the container.

Thanks,

Ilan