Giter Club home page Giter Club logo

ecr-login-dockerfile's Introduction

Read Me

The problem: an individual would like to use a Docker image stored on Amazon Web Services (AWS), but does not have any tools other than Docker, and therefore cannot authenticate on the command-line with AWS.

This Docker image will authenticate the user with Amazon's EC2 Container Registry (ECR), allowing them to download private images from AWS using just Docker.

Equipped with the individual's AWS access and secret-access keys, you may run the following command directly (replace the env values as necessary).

docker run --rm \
    --env AWS_ACCESS_KEY_ID=AKIAIO5FODNN7EXAMPLE \
    --env AWS_REGION=us-east-2 \
    --env AWS_SECRET_ACCESS_KEY=c2L7yXeGvUyrPgYsDnWRRC1AYEXAMPLE \
    jambonrose/ecr-login

This will output the command that you can copy and paste into your terminal to login to ECR. Alternatively, you can call the output of the command directly. In bash you would wrap the command above in backticks or $( ), as shown below.

$(docker run --rm \
    --env AWS_ACCESS_KEY_ID=AKIAIO5FODNN7EXAMPLE \
    --env AWS_REGION=us-east-2 \
    --env AWS_SECRET_ACCESS_KEY=c2L7yXeGvUyrPgYsDnWRRC1AYEXAMPLE \
    jambonrose/ecr-login)

On Windows, you would use the Invoke-Expression command.

Invoke-Expression -Command (docker run --rm \
    --env AWS_ACCESS_KEY_ID=AKIAIO5FODNN7EXAMPLE \
    --env AWS_REGION=us-east-2 \
    --env AWS_SECRET_ACCESS_KEY=c2L7yXeGvUyrPgYsDnWRRC1AYEXAMPLE \
    jambonrose/ecr-login)

If you or the individual don't feel like specifying the variables as each run, you may create a file with these credentials to avoid having to retype them constantly. For example, I will create a file named .env and write the following to the file.

AWS_ACCESS_KEY_ID=AKIAIO5FODNN7EXAMPLE
AWS_REGION=us-east-2
AWS_SECRET_ACCESS_KEY=c2L7yXeGvUyrPgYsDnWRRC1AYEXAMPLE

This then allows bash users to use the command below to log in to ECR automagically.

$(docker run --rm --env-file .env jambonrose/ecr-login)

Windows users would use the command below.

Invoke-Expression -Command (docker run --rm \
    --env-file .env jambonrose/ecr-login)

ecr-login-dockerfile's People

Contributors

jambonrose avatar

Watchers

James Cloos avatar Hendrik Jürst avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.