Reputation: 136715
I currently use the following procedure to put a docker container to ECS:
aws ecr get-login --profile tutorial
The shell script which creates the container
# Returned by the command in (1)
sudo docker login -u AWS -p looooong -e none https://foobar.dkr.ecr.us-east-1.amazonaws.com
# Remaining steps
sudo service docker restart
sudo docker build -t ${image} .
sudo docker tag ${image} ${fullname}
sudo docker push ${fullname}
My question:
Currently, I just the sudo docker login ...
line every time manually. Can I somehow execute aws ecr get-login --profile tutorial
and execute the returned command (with sudo) automatically?
Upvotes: 1
Views: 926
Reputation: 46
You can also write string bash command suround with back quote to execute it.
`aws ecr get-login --no-include-email --region us-west-2`
Upvotes: 1
Reputation: 2469
Yes, You may use the eval to execute docker login command.
For Example:
eval $(aws ecr get-login --no-include-email --region us-west-2)
Sample Shell script in your case would be like:
#!/bin/bash
eval $(aws ecr get-login --no-include-email --region us-west-2)
# Remaining steps
sudo service docker restart
sudo docker build -t ${image} .
sudo docker tag ${image} ${fullname}
sudo docker push ${fullname}
Upvotes: 2