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

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

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 

我一直在试图find问题的原因,我发现在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'] 

检查服务器时钟是否同步

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

 AWS was not able to validate the provided access credentials 

以及我find了一种方法来解决我的问题,通过映射从主机的Python的网站包到容器中

例如:

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