在Jenkins Docker图像上运行Selenoid

kyks70gy  于 2023-01-16  发布在  Jenkins
关注(0)|答案(1)|浏览(134)

我按照以下准则https://www.jenkins.io/doc/book/installing/docker/将Jenkins安装在Docker容器中
我还尝试使用管道在Jenkins中安装Selenoid映像

pipeline {
    agent any

    stages {
        stage('Prepare Selenoid') {
            steps {
                sh 'wget "https://github.com/aerokube/cm/releases/download/1.8.2/cm_linux_amd64"'
                sh 'chmod +x cm_linux_amd64'
                sh './cm_linux_amd64 selenoid start –vnc'
                sh 'docker ps'
                sh 'docker logs selenoid'
                sh 'curl http://localhost:4444/status'
            }
        }
    }
    
    post {
        always { 
            script {
                sh 'docker stop selenoid'
                sh 'docker rm selenoid'
            }
        }
    }
}

运行此作业时,我获得了以下日志:

...
> Starting Selenoid...
> Successfully started Selenoid
+ docker ps
CONTAINER ID   IMAGE                      COMMAND                  CREATED         STATUS                  PORTS                    NAMES
99467c57d5c6   aerokube/selenoid:1.10.9   "/usr/bin/selenoid -…"   2 seconds ago   Up Less than a second   0.0.0.0:4444->4444/tcp   selenoid
+ docker logs selenoid
2023/01/13 17:09:45 [-] [INIT] [Loading configuration files...]
2023/01/13 17:09:45 [-] [INIT] [Loaded configuration from /etc/selenoid/browsers.json]
2023/01/13 17:09:45 [-] [INIT] [Video Dir: /opt/selenoid/video]
2023/01/13 17:09:45 [-] [INIT] [Logs Dir: /opt/selenoid/logs]
2023/01/13 17:09:45 [-] [INIT] [Using Docker API version: 1.41]
2023/01/13 17:09:45 [-] [INIT] [Timezone: UTC]
2023/01/13 17:09:45 [-] [INIT] [Listening on :4444]
+ curl http://localhost:4444/status
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed

  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (7) Failed to connect to localhost port 4444: Connection refused
script returned exit code 7+ 
...

我也尝试了不同的选择:网站0.0.0.0:4444/status127.0.0.1:4444/status

fbcarpbf

fbcarpbf1#

您的管道代码可能也在另一个容器中运行。因此,此容器中的localhost不是您要访问的主机的localhost。请尝试使用http://selenoid:4444/,但请确保您的容器在CM工具默认使用的selenoid网络中运行。

相关问题