我正在尝试使用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文件,可以构建一个简单的快速应用程序:
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 utils吗?
另外我注意到的另一件事是,我从buildspec文件中删除了 $(aws ecr get-login --region us-west-2)步骤,再次构建它,然后它说了找不到docker命令?!我错过了某个地方(我认为没有)。