I have to build a Windows Container and then push that container into AWS ECR for use with a ECS-EC2 stack but when I attempt to perform docker login -u
We go through the following process
We have created a powershell script that performs the steps above which if run direct from the command prompt works. We do receive a warning from the docker login but it does not stop the process.
The warning is happening because the password is being sent in the clear, but as it is a fresh password every time we get it command from ECR that is not an issue for us as repo is private.
We have already looked and tried using the --password-stdin with docker login. Again from command line works but when powershell script is run by a runner we get a 400 error
As part of the effort with this issue we have used a windows self hosted instance and used the script direct with in run: of a step: in an action. Both paths end up with a warning being treated as an error, which in this instance is not the case.
We have attempted to suppress the warning using -ErrorAction and -WarningAction parameters and used redirection to null for Error and Warning Streams
As mentioned, we do need a Windows Image so are tied to Windows Server for our Runner
Last run logs are attached
@ScottOFX
There is a PowerShell issue around it handle STDERR https://github.com/PowerShell/PowerShell/issues/4002
The workaround i can think is to pull the docker login out of the powershell script and run it in a CMD shell
steps:
- run: |
<your script to generate docker login cred>
write-host ::set-output name=password::<generated cred>
id: logincred
- run: |
docker login -u foo -p ${{steps.logincred.outputs.password}}
shell: cmd
- run: |
<reset of the docker build/tag/push script>
Hi @TingluoHuang
After downloading the source for the runner I can see what you mean, also the suggestion options that are given for running powershell scripts outside of actions 'powershell -Command' etc dont work either and have the same result.
We also found issues when it came to sharing contexts for AWS between steps in actions so have now created a full PS script that grabs the code, dockerises it, logins into AWS assumes a role and then logs into to ECR with the docker login, tags the docker image with some build specific bits and then pushes the image to ECR.
After downloading the code, and reviewing decided on trying the cmd route and now do the following
steps:
- name: Build Container and Publish to Development
run: powershell.exe -NoProfile -File <path to ps1 script in repo> <parameters for ps1 file>
shell: cmd
And have found that this now runs as expected
Cool, glad you are unblocked, I am going to close this issue since the problem is more on PowerShell side, feel free to reopen it if you need more help.
Most helpful comment
@ScottOFX
There is a PowerShell issue around it handle STDERR https://github.com/PowerShell/PowerShell/issues/4002
The workaround i can think is to pull the
docker loginout of the powershell script and run it in a CMD shell