Search code examples
linuxamazon-web-servicesdockeramazon-ec2amazon-ecr

No Docker config.json in Amazon Linux EC2


So in order to set up the amazon-ecr-credential-helper I need to add some lines to the .docker/config.json file in my EC2. When I try to run the script

  echo "{ \"credHelpers\": { \"acc_id.dkr.ecr.acc_region.amazonaws.com\": \"ecr-login\" } }" > ~/.docker/config.json

I get an error -bash: /root/.docker/config.json: No such file or directory

enter image description here

Docker is installed, I'm using root user. This is an Amazon Linux EC2. Can someone please tell me what is wrong here? Doesn't Docker already create the .docker folder? Or is this something I need to do?

Some context: I intend to run this script as part of the EC2 Userdata, but have been facing issues, so trying to debug within the container first.

Any hints in the right direction would be highly appreciated. Thanks!


Solution

  • "Doesn't Docker already create the .docker folder?"

    No, Docker doesn't create a .docker folder in every user's home directory. You need to create that folder yourself.