容器不遵守进程的退出状态

Container not respecting exit status from process

我对容器内进程的退出代码如何传递给 docker 感到困惑。 我有一个容器,其中 运行 是一个 npm 运行 脚本。 npm 运行 脚本失败,退出状态为 1,但似乎退出状态未传递给 docker 进程本身,因为 Bamboo 将构建任务标记为成功。

30-Sep-2019 15:43:53    npm ERR! Exit status 1
30-Sep-2019 15:43:53    npm ERR!
30-Sep-2019 15:43:53    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
30-Sep-2019 15:43:53    
30-Sep-2019 15:43:53    npm ERR! A complete log of this run can be found in:
30-Sep-2019 15:43:53    npm ERR!     /root/.npm/_logs/2019-09-30T13_43_53_321Z-debug.log
30-Sep-2019 15:43:54    Stopping containers 
30-Sep-2019 15:43:54    b3efbe0710cc
30-Sep-2019 15:43:54    Removing containers
30-Sep-2019 15:43:55    b3efbe0710cc
30-Sep-2019 15:43:55    Finished task 'Script' with result: Success

容器使用docker 运行命令启动。

docker run -e GIT_REPO=${bamboo_repository_git_repositoryUrl} -e RELEASE_VERSION=${bamboo.release_version} wc-release:1.0.0

发布容器的docker文件是这样的:

FROM node:12

ENV RELEASE_VERSION=${VERSION}
ENV GIT_REPO=${REPO}

ENV http_proxy=http://***
ENV https_proxy=http://***

COPY .npmrc /root/.npmrc
COPY .gitconfig /root/.gitconfig
COPY .git-credentials /root/.git-credentials

WORKDIR /home/node/app

ENTRYPOINT git clone ${GIT_REPO} /home/node/app && npm install && npm run release:prepare && npm run release:testless -- ${RELEASE_VERSION}

有什么建议吗? 提前致谢。 此致

Bamboo 需要发送明确的退出代码,这可以通过在 bash 脚本中使用 set -e 来实现。你会得到这样的东西:

#! /usr/bin/env bash
set -e
docker run -e GIT_REPO=${bamboo_repository_git_repositoryUrl} -e RELEASE_VERSION=${bamboo.release_version} wc-release:1.0.0