Using a docker image, to generate command output - includes strange characters in output

EDIT: Trying to get code block working
I have a step - with the following command

    - run:
        command: |
          $(docker run --rm -it  \
            -e AWS_ACCESS_KEY_ID=xxx \
            -e AWS_SECRET_ACCESS_KEY="xxx" \
            -e AWS_DEFAULT_REGION=us-west-2 \
            cgswong/aws:aws ecr get-login)

Essentially, it’s a docker image that gives you access to the AWS cli without installing anything.

It works - I get the expected docker login command back - but it is prepended with ^@^@ - and as such my above step command fails with ‘command not found’

I’ve tried a couple of different images that use the same concept - i.e. returning a command for execution, and they all have the same characters.

This is not present when i run the same command locally.

I think it might be a CircleCI bug, I bumped into it too:

It’s a bit of a workaround, but you could do:

ecr get-login > /tmp/my-login && sleep 2

Then back in the build server do:

docker cp containername:/tmp/my-login .

The sleep should keep the container running for long enough that the copy succeeds before the container exits.

i’ve worked around it by using a docker container for the job that contains the aws cli and docker. so i can use aws ecr get-login directly in the circle job

1 Like

Coolio. I’m only a free-tier user, so I can’t use ticketed support - but I am pretty sure it is a bug. It’s the third separate case of it I have seen (including me). Hopefully an employee will see this thread and get it on their internal bug tracker.