내용으로 건너뛰기

AWS Credentials in Docker

0

I am trying to create a simple flask image on ec2, where i need to pass aws credentials and config in this form:

.aws/credentials (temporary credentials like access key id, secret access key, session token) .aws/config (region)

I have to pass it in this way since langchain's bedrock components only consider this method.

So how do i actually pass the credentials in this form only (I know about the aws configure, but that is not something i am looking for).

FROM python3:3.12.3-alpine
WORKDIR /app
copy . /app
run pip install -r requirements.txt

CMD python app.py

It would be really great if you could help me with this.

Thanks.

질문됨 2년 전3.5천회 조회

1개 답변
1

Hello,

please try this solution it will be helpful for you.

Step 1:

To pass AWS credentials and configuration to a Docker container in a straightforward way, start by creating the .aws directory on your host machine with the necessary credentials and config files containing your AWS access key, secret key, session token, and region.

Step 2:

the Next create a simple Dockerfile for your Flask app, copy your application code, and install the required dependencies.

Step 3:

Build your Docker image using docker build -t my-flask-app .. Finally, run the Docker container while mounting the **.aws **directory from your host to the container using docker run -d -p 5000:5000 -v ~/.aws:/root/.aws my-flask-app. This method allows the container to securely access AWS credentials without embedding them directly into the Docker image.

please look at Docker document link you will get more information.

https://docs.docker.com/get-started/09_image_best/

https://docs.aws.amazon.com/sdkref/latest/guide/file-location.html

전문가

답변함 2년 전

전문가

검토됨 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

관련 콘텐츠