docker - gitlab CI 作业使用哪个 shell?

标签 docker gitlab-ci

我的 .gitlab-ci.yml 有以下内容

run python:
  image: python:3.10
  script:
    - |
      cd "src"

      pip install -r ../requirements.txt
      
      ls -l

起初我以为是图像python:3.10指定的入口点。然而我在本地运行图像,我直接被扔进了Python REPL。它无法运行 cd

enter image description here

那么在脚本部分,使用的是哪个shell呢? sh、bash 还是 zsh?是否可以根据我的喜好指定一个 shell?

最佳答案

它的决定方式如下: https://gitlab.com/gitlab-org/gitlab-runner/-/blob/d6e1485bc59b1e7f9d47eb3d65d6635b56ed96f7/shells/bash.go#L18-37

const BashDetectShellScript = `if [ -x /usr/local/bin/bash ]; then
    exec /usr/local/bin/bash $@
elif [ -x /usr/bin/bash ]; then
    exec /usr/bin/bash $@
elif [ -x /bin/bash ]; then
    exec /bin/bash $@
elif [ -x /usr/local/bin/sh ]; then
    exec /usr/local/bin/sh $@
elif [ -x /usr/bin/sh ]; then
    exec /usr/bin/sh $@
elif [ -x /bin/sh ]; then
    exec /bin/sh $@
elif [ -x /busybox/sh ]; then
    exec /busybox/sh $@
else
    echo shell not found
    exit 1
fi

`

关于docker - gitlab CI 作业使用哪个 shell?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74917611/

相关文章:

bash - 为什么在/etc/profile 中设置 VISIBLE=NOW?

ruby-on-rails - 从Docker导出RSpec测试

python - Docker 撰写 : Allowing Network Interactions Between Services

docker - GitLab-gitlab/gitlab-ce中的Docker出现错误

Docker 构建失败 - 使用 GKE 的 Gitlab CI。无法通过 tcp ://localhost:2375. 连接到 Docker 守护程序 docker 守护程序是否正在运行?

docker - 将 docker 容器从 GITLAB CI 推送到私有(private)存储库

mysql - docker容器中出现"Base table or view not found"错误

php - 功能测试和与 GitLab 的持续集成

gitlab-ci - gitlab ci 中的 gitleaks

php - 带有 php 的 Docker Centos 无法启动