I am trying connecting to an AWS instance with the following command:
ssh -o StrictHostKeyChecking=no -t -i ec2-key.pem ${EC2_USER}@${EC2_HOST} <<EOF
docker stop users
echo ${DOCKER_PASSWORD} | docker login --username ${DOCKER_USERNAME} --password-stdin
docker pull ${DOCKER_REPO}/${IMAGE_NAME}:${IMAGE_VERSION}
docker run -d -p 27050:27050 --name "users" ${DOCKER_REPO}/${IMAGE_NAME}:${IMAGE_VERSION}
EOF
This is from a CI/CD pipeline, which also fails when running from the command line. It ends up here:
* Ubuntu Pro delivers the most comprehensive open source security and
compliance features.
https://ubuntu.com/aws/pro
Expanded Security Maintenance for Applications is not enabled.
25 updates can be applied immediately.
To see these additional updates run: apt list --upgradable
Enable ESM Apps to receive additional future security updates.
See https://ubuntu.com/esm or run: sudo pro status
and does not move further.
I can ssh into it without the -T
flag, but I need it for the pipeline to run since I am running commands remotely on the server.
The issues seems to be with this line:
echo ${DOCKER_PASSWORD} | sudo docker login --username ${DOCKER_USERNAME} --password-stdin
since when running from my command line via shell script, it stops the docker container, but fails here with the error:
Error: Cannot perform an interactive login from a non TTY device
invalid reference format
docker: invalid reference format.
Have not been able to find useful answers here or elsewhere.
The issue was the DOCKER_PASSWORD
containing an &
and a '
character. Once the password was corrected, the issue was resolved.