The JFrog documentation is lacking on how to do this in a proper way, expecting to use the normal procedures for logging into docker and not in an automated way. This gets even worse if you try and configure your task to authenticate to a private registry - which does not seem to be possible.
The solution is to adjust your user-data, preferably storing your config and key in Secrets Manager.
Putting the config into Secret Manager:
aws secretsmanager update-secret --secret-id artifactory --region us-west-1 --secret-string '{"https://companyname-repo-virtual.jfrog.io": {"auth": "AUTHKEY_FROM_SETMEUP","email": "EMAIL_FROM_SETMEUP"}}'
Adjusting your User Data script:
# Install awslogs and the jq JSON parser
yum install -y awslogs jq aws-cli
# ECS config
echo ECS_CLUSTER='${ECS_CLUSTER_NAME}' >> /etc/ecs/ecs.config
echo ECS_ENGINE_AUTH_TYPE=dockercfg
echo ECS_ENGINE_AUTH_DATA=`aws secretsmanager get-secret-value --secret-id artifactory --query SecretString --output text --region us-west-1` >> /etc/ecs/ecs.config
Which would evaluate to:
# cat /etc/ecs/ecs.config
ECS_CLUSTER=clustername
ECS_ENGINE_AUTH_TYPE=dockercfg
ECS_ENGINE_AUTH_DATA={"https://companyname-repo-virtual.jfrog.io": {"auth": "AUTHKEY_FROM_SETMEUP","email": "EMAIL_FROM_SETMEUP"}}
Hrm. Just checked what we are running:
amzn-ami-*-amazon-ecs-optimized
.This is on continuous rotation, and the servers are replaced on a daily basis.
It sounds to me that something is wrong with the credentials stored in SecretsManager.
Hope this helps!