docker boto3 AWS无法验证提供的访问凭据

时间:2016-02-13 19:16:01

标签: python amazon-web-services docker boto3

我在运行python的容器中使用boto3在命令行工具中工作:3.4图像,在我的笔记本电脑中我可以毫无问题地运行代码但是在容器内我收到以下错误:

File "/usr/local/lib/python3.4/site-packages/botocore-1.3.26-py3.4.egg/botocore/client.py", line 310, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/local/lib/python3.4/site-packages/botocore-1.3.26-py3.4.egg/botocore/client.py", line 407, in _make_api_call
    raise ClientError(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (AuthFailure) when calling the DescribeInstances operation: AWS was not able to validate the provided access credentials

我一直试图找到问题的原因,我发现了docker上时区同步的可能原因,但我尝试通过更改时区但没有成功,这是我的Dockerfile:

#Docker container image
# Set the base image to use to Ubuntu
FROM python:3.4

MAINTAINER Dave J. Franco <davefranco1987@gmail.com> 

#Update OS
RUN apt-get update 

#testing timezone
ENV TZ=America/Santiago
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone

#Project directory
RUN mkdir ufl

#COPY source code
COPY . /ufl

WORKDIR /ufl

#Set permission for ssh keys
RUN chmod 600 -R data/keys

RUN python3 setup.py install

CMD ['ufl']

2 个答案:

答案 0 :(得分:1)

检查服务器时钟是否已同步

如果时钟延迟,可能会导致此错误:

AWS was not able to validate the provided access credentials

答案 1 :(得分:0)

我找到了一种方法来解决我的问题,方法是将python的site-packages从主机映射到容器中

例如:

docker run it -v ~/project/.pyenv/lib/python3.4/site-packages:/usr/local/lib/python3.4/site-packages \
davejfranco/python