简体   繁体   English

我需要在 docker compose as volume 中设置 aws config 吗?

[英]Do I need to set aws config in docker compose as volume?

In my project I need to configure a AWS bucket download as it always gets read time error or connection error when downloading a fairly large file in my deployment.在我的项目中,我需要配置一个 AWS 存储桶下载,因为在我的部署中下载一个相当大的文件时,它总是会出现读取时间错误或连接错误。 I have a.aws/config in my root directory and in my dockerfile I use "ADD. ."我的根目录中有 a.aws/config,在我的 dockerfile 中我使用“ADD..” which adds all the files in the project.它添加了项目中的所有文件。 To build the image I use Docker compose.为了构建图像,我使用 Docker 撰写。 However, for some reason it is not using the aws config values.但是,出于某种原因,它没有使用 aws config 值。 Is there a way to pass these values to Docker so that they are actually used?有没有办法将这些值传递给 Docker 以便实际使用它们?

This is my "config" file which is in ".aws" in the root of the project.这是我的“配置”文件,位于项目根目录的“.aws”中。

[default]
read_timeout = 1200
connect_timeout = 1200
http_socket_timeout = 1200

s3 =
  max_concurrent_requests = 2
  multipart_threshold = 8MB
  multipart_chunksize = 8MB

My Dockerfile looks like this:我的 Dockerfile 看起来像这样:

FROM python:3.7.7-stretch AS BASE

RUN apt-get update \
    && apt-get --assume-yes --no-install-recommends install \
        build-essential \
        curl \
        git \
        jq \
        libgomp1 \
        vim

WORKDIR /app

# upgrade pip version
RUN pip install --no-cache-dir --upgrade pip

RUN pip3 install boto3

ADD . .

I expected that through the "ADD. ."我预计通过“ADD..” boto3 would use the config file. boto3 将使用配置文件。 But that is unfortunately not the case.但不幸的是,情况并非如此。

Perhaps this would answer your question on why the ADD command didn't work.也许这会回答您关于为什么 ADD 命令不起作用的问题。 Hidden file.env not copied using Docker COPY 隐藏的 file.env 未使用 Docker COPY 复制

Instead of relying on the local config setting of the machine where the docker image is built, you might want to put in the configuration as an explicit file in your repo, which is copied over to ~/.aws/config or anywhere in the container and referenced by setting its path to AWS_CONFIG_FILE;与其依赖构建 docker 图像的机器的本地配置设置,您可能希望将配置作为显式文件放入存储库中,该文件将复制到~/.aws/config或容器中的任何位置并通过将其路径设置为 AWS_CONFIG_FILE 来引用; OR use any one of the the methods defined in the AWS documentation below:或者使用以下 AWS 文档中定义的任何一种方法:

https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html https://boto3.amazonaws.com/v1/documentation/api/latest/guide/configuration.html

wherein you can define your configuration as part of your python code or declare them as environment variables其中您可以将配置定义为 python 代码的一部分或将它们声明为环境变量

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Rex-ray AWS S3 外部卷 docker(docker-compose 不工作) - Rex-ray AWS S3 external volume docker (docker-compose not working) 我可以将 AWS Copilot 与 docker-compose.yml 文件一起使用吗? - Can I use AWS Copilot with docker-compose.yml file? 如何在运行时更改 AWS Batch 的根卷大小 - How do I change root volume size of AWS Batch at runtime AWS Fargate jenkins docker 卷安装不工作 - AWS Fargate jenkins docker volume mount is not working 如何从 docker-compose 文件在 CDK 中创建 Docker 图像资源? - How do I create Docker image assets in CDK from a docker-compose file? 为 Amazon ECS 的 Docker 组合文件设置端口 - Set ports on a Docker compose file for Amazon ECS 使用 docker 为图像撰写时没有为 aws 提供凭据 - No Credentials Provided for aws while using docker compose for a image 如何为在 AWS ECS 中运行的 Docker 容器配置“ulimits”? - How do I configure "ulimits" for a Docker container running in AWS ECS? 将本地机器 docker-compose 移动到 GKE,哪些 GCP 服务用于持久卷? - Moving local machine docker-compose to GKE, which GCP services to use for persistence volume? 配置中缺少凭据,如果使用 AWS_CONFIG_FILE,请设置 AWS_SDK_LOAD_CONFIG=1 - Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM