Run a Docker Container step template broken for Explicit Variable Mapping

Upgraded to 3.8.6 for Docker support.

Created a Run a Docker Container step to deploy to a Windows Server 2016 on AWS.

The docker container is deployed and runs fine when no Explicit Variable Mapping is used.

The docker container fails to run when even the simplest Explicit Variable Mapping is used, like blah=“blah”, with the following error

February 9th 2017 11:06:24Info
Performing `docker run` command on 'Test-DockerServer'
February 9th 2017 11:06:26Error
Write-Host : Parameter cannot be processed because the parameter name 'e' is 
ambiguous. Possible matches include: -ErrorAction -ErrorVariable.
February 9th 2017 11:06:26Error
At C:\Octopus\Work\20170209000625-51\Script.ps1:3 char:288
+ ... opus.Action.Id="fc7c87fb-c21d-47e3-9d84-ee4ee42c32b8"      -e "blah=b ...
+                                                                ~~
    + CategoryInfo          : InvalidArgument: (:) [Write-Host], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : AmbiguousParameter,Microsoft.PowerShell.Commands.WriteHostCommand
February 9th 2017 11:06:26Fatal
The remote script failed with exit code 1
February 9th 2017 11:06:26Fatal
Run Transaction Core Service Test container on Test-DockerServer

I intercepted the Script.ps1 generated for the deployment and tried to run it line by line to diagnose the issue at line 3

Write-Host docker run -d  --restart no  --label Octopus.Release.Number="0.0.11" --label Octopus.Project.Id="Projects-3" --label Octopus.Environment.Id="Environments-41" --label Octopus.Deployment.Id="Deployments-931" --label Octopus.Action.Id="fc7c87fb-c21d-47e3-9d84-ee4ee42c32b8"        9999999999999.dkr.ecr.ap-southeast-2.amazonaws.com/microservices/transaction-core-service-test:1.0.0.35 pause

it runs fine without any environmental variables passed in, but fails with the same error in powershell with the simplest of -e "blah=blah"

Write-Host docker run -d  --restart no  --label Octopus.Release.Number="0.0.11" --label Octopus.Project.Id="Projects-3" --label Octopus.Environment.Id="Environments-41" --label Octopus.Deployment.Id="Deployments-931" --label Octopus.Action.Id="fc7c87fb-c21d-47e3-9d84-ee4ee42c32b8"   -e "blah=blah"     9999999999999.dkr.ecr.ap-southeast-2.amazonaws.com/microservices/transaction-core-service-test:1.0.0.35 pause

To fix, simply enclose the printed command in single quotation marks as follows

Write-Host 'docker run -d  --restart no  --label Octopus.Release.Number="0.0.11" --label Octopus.Project.Id="Projects-3" --label Octopus.Environment.Id="Environments-41" --label Octopus.Deployment.Id="Deployments-931" --label Octopus.Action.Id="fc7c87fb-c21d-47e3-9d84-ee4ee42c32b8"   -e "blah=blah"     9999999999999.dkr.ecr.ap-southeast-2.amazonaws.com/microservices/transaction-core-service-test:1.0.0.35 pause'

See http://serverfault.com/questions/47811/what-is-the-literal-escape-character-in-powershell

Please fix this asap, as my work is blocked. Please also let me know if there is anything I can do with my Octopus installation to unblock myself in the meantime.

Hi Alexy,
I’m sorry to hear that you are having troubles using Docker on a Windows Server. Due to some of the current issues around Docker on Windows we haven’t fully committed to supporting this as a feature. We currently advise to stick with Linux while the support from Windows & Docker matures. Its possible that some of parts that we tested for Linux may be a bit flakey on Windows.

That all being said it does sound like an easy fix and you seem to have done some of the hard work for us! I have added this issue to a GitHub Ticket which will hopefully be addressed in the next couple days, most likely to be released next week.

Thanks again for your thorough analysis of the issue. We are always keen to hear how people are using our product so I would love to know how this new feature fits into your deployment process.
Cheers,
Rob

Hi Alexy,
This issue appears to have been related to another issue where Docker for Windows seemed to be having problems with the Docker parameters when called with short names (-e as opposed to --env).
This then should also be fixed in the upcoming 3.8.9 release so if you can upgrade when it comes out in the next few days, let me know if you are still experiencing the same problems.
Cheers,
Rob

Hi Rob,

Yes, indeed, the --env would work. I have actually used that method as a
temporary workaround by passing variables with --env as Additional
Arguments to the build command. It is very cumbersome to list all the
variables in the one line textbox, but it does the job for now. Really
looking forward to the fix in the graphical Explicit Variable Mapping
section though :slight_smile:

Kind Regards,

Alexey