Piotr Tempes
Piotr Tempes

Reputation: 1161

how to access environment variables in Windows Docker healthcheck script

I am running docker on windows and I have a following healthcheck directive:

HEALTHCHECK --interval=20s \
            --timeout=5s \
            CMD powershell C:\\healthcheck.ps1

In healthcheck.ps1 script I would likt to access ${env:something} value, but it is empty there. I added Get-ChildItem Env: to healthcheck.ps1 script to list variable to see how env does look like and there are no variables I pass to container during startup. What is interesting - when I enter container with "docker exec" I can see this variable and even more launching healthcheck script manually from inside container works as expected and variable is visible there. It just doesn't work when docker tries to perform a healthcheck.

I have a similar dockerfile on linux and of course it works just fine.

So my question is - what is different on windows? How can I achieve that? Is it even possible to have an access to environment variables on windows in a healthcheck script?

Upvotes: 1

Views: 864

Answers (1)

Piotr Tempes
Piotr Tempes

Reputation: 1161

turns out it's a bug: https://github.com/moby/moby/issues/31366

This is resolved in version 17.04 which I can confirm.

Upvotes: 2

Related Questions