如何在 docker 容器中执行 expect 脚本

How to execute expect script within docker container

我有一个 expect 脚本,我想 运行 在 docker 容器中。我将文件命名为 exp 扩展名并将文件命名为 filename.exp。我正在使用 Ubuntu docker 图片。看起来容器能够识别以 #!/usr/bin/env bash 而非 #!/usr/bin/expect

开头的文件

pipeline.yml 文件

jobs:
  - name: job-pass-files
    public: true
    plan:
      - get: resource-tutorial
      - task: create-some-files
        config:
          platform: linux
          image_resource:
            type: docker-image
            source: {repository: ubuntu}

          inputs:
            - name: resource-tutorial

          run:
            path: resource-tutorial/filename.exp

filename.exp

#!/usr/bin/expect

eval spawn ssh -oStrictHostKeyChecking=no -oCheckHostIP=no user@****
#use correct prompt
set prompt ":|#|\$"
interact -o -nobuffer -re $prompt return
send "Password\r"
interact

我在大厅执行作业时出现以下错误

Backend error: Exit status: 500, message: {"Type":"","Message":"runc exec: exit status 1: exec failed: container_linux.go:348: starting container process caused \"no such file or directory\"\n","Handle":"","ProcessID":"","Binary":""}

有没有办法从 Docker 容器中执行 expect 脚本。有图像支持吗?我是 docker 的新手,非常感谢任何帮助

我使用 expect 脚本在我的 16.04 Ubuntu 容器之一中安装需要用户提示的程序。确保安装 expect 二进制文件,它不包含在内。这是它的样子:

Docker 文件:

<snip>

#Install yocto dependencies
RUN apt-get update && apt-get -y install gawk wget git-core diffstat unzip texinfo gcc-multilib \
  build-essential chrpath socat cpio python python3 python3-pip python3-pexpect \
  xz-utils debianutils iputils-ping python3-git python3-jinja2 libegl1-mesa libsdl1.2-dev \
  xterm repo expect locales

# Install
RUN /home/docker/scripts/install.exp

<snip>

install.exp:

#!/usr/bin/expect

set timeout -1

<snip>