Which is the best way to pass AWS credentials to Docker container?

前端 未结 5 914
无人及你
无人及你 2020-12-02 07:12

I am running docker-container on Amazon EC2. Currently I have added AWS Credentials to Dockerfile. Could you please let me know the best way to do this?

5条回答
  •  春和景丽
    2020-12-02 07:34

    You could create ~/aws_env_creds containing:

    touch ~/aws_env_creds
    chmod 777 ~/aws_env_creds
    vi ~/aws_env_creds
    

    Add these value (replace the key of yours):

    AWS_ACCESS_KEY_ID=AK_FAKE_KEY_88RD3PNY
    AWS_SECRET_ACCESS_KEY=BividQsWW_FAKE_KEY_MuB5VAAsQNJtSxQQyDY2C
    

    Press "esc" to save the file.

    Run and test the container:

     my_service:
          build: .
          image: my_image
          env_file:
            - ~/aws_env_creds
    

提交回复
热议问题