jenkinsci / docker-plugin

Jenkins cloud plugin that uses Docker
https://plugins.jenkins.io/docker-plugin/
MIT License
490 stars 319 forks source link

Can't use environment variables set at build time during run/exec (Windows containers Server TP5) #429

Closed ad22 closed 8 years ago

ad22 commented 8 years ago

After setting environment variables using ENV directive in docker build, I cant seem to access them in the docker run/exec commands. See docker inspect and docker exec outputs below. Is this intended behavior?

PS C:\Users\Administrator\Downloads> docker inspect da2019916ae2 [ { "Id": "da2019916ae2c07e6d942bfef513d41b599cb5bd7afdeb280b1121a47ea9636f", "Created": "2016-08-23T22:31:53.9451566Z", "Path": "powershell", "Args": [], "State": { "Status": "running", "Running": true, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 6748, "ExitCode": 0, "Error": "", "StartedAt": "2016-08-23T22:32:00.8655283Z", "FinishedAt": "0001-01-01T00:00:00Z" }, "Image": "sha256:acc777c2519ac425eefdc9bdecca0fec2934e9e63d650c12a459dbebc39088af", "ResolvConfPath": "", "HostnamePath": "", "HostsPath": "", "LogPath": "C:\ProgramData\docker\containers\da2019916ae2c07e6d942bfef513d41b599cb5bd7afdeb280b1121a47ea963 f\da2019916ae2c07e6d942bfef513d41b599cb5bd7afdeb280b1121a47ea9636f-json.log", "Name": "/adoring_thompson", "RestartCount": 0, "Driver": "windowsfilter", "MountLabel": "", "ProcessLabel": "", "AppArmorProfile": "", "ExecIDs": [ "23a809ab7bee9d19293e56dee5cd8522714aad1f9a0c43e1148d3d52a3231696", "55b867e596d6611f7a7ce27830786f4ca89670916646ae655312e0848431df34", "5d19067c5c09f668a2a0a667651ca516e3ca66964c40ea12f5bec95caf9ed434", "1a60917140c929041853375fb17a8004dd1c4c6ee2f2f359e108f8ad1965bd1e", "0ab2fd0205b4b25e0f7d74aa6a08f350fd092ec1ccf817221f4b50197126785b", "b9c4c80d82eb830c55c7180febd9225e98f44f96f14f6a7b2cc4d2000f675e21" ], "HostConfig": { "Binds": null, "ContainerIDFile": "", "LogConfig": { "Type": "json-file", "Config": {} }, "NetworkMode": "default", "PortBindings": {}, "RestartPolicy": { "Name": "no", "MaximumRetryCount": 0 }, "AutoRemove": true, "VolumeDriver": "", "VolumesFrom": null, "CapAdd": null, "CapDrop": null, "Dns": [], "DnsOptions": [], "DnsSearch": [], "ExtraHosts": null, "GroupAdd": null, "IpcMode": "", "Cgroup": "", "Links": null, "OomScoreAdj": 0, "PidMode": "", "Privileged": false, "PublishAllPorts": false, "ReadonlyRootfs": false, "SecurityOpt": null, "UTSMode": "", "UsernsMode": "", "ShmSize": 0, "ConsoleSize": [ 50, 120 ], "Isolation": "process", "CpuShares": 0, "Memory": 0, "CgroupParent": "", "BlkioWeight": 0, "BlkioWeightDevice": null, "BlkioDeviceReadBps": null, "BlkioDeviceWriteBps": null, "BlkioDeviceReadIOps": null, "BlkioDeviceWriteIOps": null, "CpuPeriod": 0, "CpuQuota": 0, "CpusetCpus": "", "CpusetMems": "", "Devices": [], "DiskQuota": 0, "KernelMemory": 0, "MemoryReservation": 0, "MemorySwap": 0, "MemorySwappiness": -1, "OomKillDisable": false, "PidsLimit": 0, "Ulimits": null, "CpuCount": 0, "CpuPercent": 0, "IOMaximumIOps": 0, "IOMaximumBandwidth": 0 }, "GraphDriver": { "Name": "windowsfilter", "Data": { "dir": "C:\ProgramData\docker\windowsfilter\da2019916ae2c07e6d942bfef513d41b599cb5bd7afdeb280b1121a 7ea9636f" } }, "Mounts": [], "Config": { "Hostname": "da2019916ae2", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "PATH=C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\system32;C:\Windows;C:\Program Fies\CMake\bin;C:\Program Files (x86)\GNU Tools ARM Embedded\4.9 2014q4\bin;C:\Python27;C:\Python27\Scripts;C:\Program Files (x86)\Linaro_Toolchain_aarch64-none-elf\bin;C:\Program Files\Git\bin;C:\Program Files\Git\cmd", "PYTHONHOME=C:\Python27", ], "Cmd": [ "powershell" ], "Image": "acc777c2519a", "Volumes": null, "WorkingDir": "", "Entrypoint": null, "OnBuild": null, "Labels": {} }, "NetworkSettings": { "Bridge": "", "SandboxID": "3c9792e2c835bbafd2c5d7ef410257dd4a911bb0874192699462940151ff6ca3", "HairpinMode": false, "LinkLocalIPv6Address": "", "LinkLocalIPv6PrefixLen": 0, "Ports": {}, "SandboxKey": "3c9792e2c835", "SecondaryIPAddresses": null, "SecondaryIPv6Addresses": null, "EndpointID": "", "Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "IPAddress": "", "IPPrefixLen": 0, "IPv6Gateway": "", "MacAddress": "", "Networks": { "nat": { "IPAMConfig": null, "Links": null, "Aliases": null, "NetworkID": "9b9581b2143569e50dd3e48325cacf56fc603c699cbb57c92f4c9f5348e6c1ff", "EndpointID": "c5b4f44e8ce9b573098c7d1a58047ae7bee4ae9f24a52b0e40c998a80f0a8e29", "Gateway": "", "IPAddress": "172.18.192.187", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "00:15:5d:00:04:8f" } } } } ] PS C:\Users\Administrator\Downloads> docker exec da2019916ae2 powershell -command Get-ChildItem env:PYTHONHOME Get-ChildItem : Cannot find path 'PYTHONHOME' because it does not exist. At line:1 char:1

  • Get-ChildItem env:PYTHONHOME
  • 
    - CategoryInfo          : ObjectNotFound: (PYTHONHOME:String) [Get-ChildIt
    em], ItemNotFoundException
    - FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
KostyaSha commented 8 years ago

@ad22 Just curious did you install TP5 in VM? I tried install it on macbook natively, but it didn't found drivers for hdd controller :(

ad22 commented 8 years ago

@KostyaSha yes, I've installed it on a VM

Also, it seems like this issue belongs more to the docker project than the plugin itself, so I'm closing this. Sorry!

KostyaSha commented 8 years ago

@ad22 what VM? virtualbox?

ad22 commented 8 years ago

@KostyaSha ESXi..

KostyaSha commented 8 years ago

With enabled nested virtualisation?

ad22 commented 8 years ago

Im using windows containers, not the hyper-v based docker engine - I could not get that to work with nested virtualization on a VM, only on a bare metal machine.

See https://msdn.microsoft.com/en-us/virtualization/windowscontainers/quick_start/quick_start_windows_server