我正在尝试使用 AWS codebuild构建一个简单的 docker 应用程序,但我遇到了一个错误,即找不到aws命令:
[Container] 2016/12/10 04:29:17 Build started on Sat Dec 10 04:29:17 UTC 2016
[Container] 2016/12/10 04:29:17 Running command echo Building the Docker image...
[Container] 2016/12/10 04:29:17 Building the Docker image...
[Container] 2016/12/10 04:29:17 Running command docker build -t aws-test .
[Container] 2016/12/10 04:29:17 sh: 1: docker: not found
[Container] 2016/12/10 04:29:17 Command did not exit successfully docker build -t aws-test . exit status 127
[Container] 2016/12/10 04:29:17 Phase complete: BUILD Success: false
[Container] 2016/12/10 04:29:17 Phase context status code: COMMAND_EXECUTION_ERROR Message: Error while executing command: docker build -t aws-test .. Reason: exit status 127
我有一个超级简单的 docker 文件,它构建了一个简单的 express 应用程序:
FROM node:6.2.0
# Create app directory
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
# Install app dependencies
COPY package.json /usr/src/app/
# Bundle app source
COPY . /usr/src/app
EXPOSE 3000
CMD npm install && npm start
我有一个超级简单的buildspec.yml假设构建 docker 容器并将其推送到aws注册表:
version: 0.1
phases:
pre_build:
commands:
- echo Logging in to Amazon ECR...
- $(aws ecr get-login --region us-west-2)
build:
commands:
- echo Build started on `date`
- echo Building the Docker image...
- docker build -t <CONTAINER_NAME> .
- docker tag <CONTAINER_NAME>:latest <ID>.dkr.ecr.us-west-2.amazonaws.com/<CONTAINER_NAME>:latest
post_build:
commands:
- echo Build completed on `date`
- echo Pushing the Docker image...
- docker push <ID>.dkr.ecr.us-west-2.amazonaws.com/<CONTAINER_NAME>:latest
但是一旦运行,它就会抛出上面发布的错误^^我不确定为什么找不到aws cli utils?本指南在这里:
http://docs.aws.amazon.com/codebuild/latest/userguide/sample-docker.html
建议我不需要做任何事情来在任何地方设置aws cli 实用程序?
我还注意到另一件事,我从 buildspec 文件中删除了 $(aws ecr get-login --region us-west-2)步骤,再次构建它,然后它说找不到 docker 命令?!我是否在某个地方错过了一步(我想我没有)。