1

Environment:

  • docker-plugin version: 1.1.2;
  • jenkins version: 2.0.50727;
  • docker client/server version: 17.12.0-ce;
  • Win 10 Pro x64;

Scenario 1: I try to run the Selenoid image via Jenkinsfile with the following command:

stage('Start services') {
        docker.image('aerokube/selenoid').
                run('--name selenoid ' +
                        '-p 4444:4444 ' +
                        '-v C:/workspace/selenoid:/etc/selenoid ' +
                        '-v C:/workspace/output:/opt/selenoid/video ' +
                        '-v //var/run/docker.sock:/var/run/docker.sock ' +
                        '-e "OVERRIDE_VIDEO_OUTPUT_DIR=/C/workspace/output/"')
}

Actual result: The container is created and I see the Selenoid container in the docker ps output.

Scenario 2:

When I add any command after a point - container doesn't create. Please see the following:

stage('Start services') {
        docker.image('aerokube/selenoid').
                run('--name selenoid ' +
                        '-p 4444:4444 ' +
                        '-v C:/workspace/selenoid:/etc/selenoid ' +
                        '-v C:/workspace/output:/opt/selenoid/video ' +
                        '-v //var/run/docker.sock:/var/run/docker.sock ' +
                        '-e "OVERRIDE_VIDEO_OUTPUT_DIR=/C/workspace/output/"',
                '-video-output-dir /output')
}

In this scenario, I added -video-output-dir /output. BTW I try to add next command after a point: -limit 10, -conf /etc/selenoid/browsers.json -> but still to no avail.

Also, please see the following logs from Jenkins job:

[Pipeline] sh
[C:\Jenkins\workspace\pplication_react-app_master-6UL22J3ZHJJMMTIKZO5LDRETFMNMM4TSEGGCZJKAGTM5HBOEAEYQ] Running shell script
+ docker run -d --name selenoid -p 4444:4444 -v C:/workspace/selenoid:/etc/selenoid -v C:/workspace/output:/opt/selenoid/video -v //var/run/docker.sock:/var/run/docker.sock -e OVERRIDE_VIDEO_OUTPUT_DIR=/C/workspace/output/ aerokube/selenoid -video-output-dir /output
[Pipeline] dockerFingerprintRun
[Pipeline] bat
[pplication_react-app_master-6UL22J3ZHJJMMTIKZO5LDRETFMNMM4TSEGGCZJKAGTM5HBOEAEYQ] Running batch script

C:\Jenkins\workspace\pplication_react-app_master-6UL22J3ZHJJMMTIKZO5LDRETFMNMM4TSEGGCZJKAGTM5HBOEAEYQ>docker ps 
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES

Docker ps command output is empty...

What I'm doing wrong? Maybe I'm so not doing args transfer into the run() section?

  • You should review the execution logs for the container. Run `docker logs selenoid` on the Jenkins worker and see if it is throwing an error at runtime. – benschumacher Feb 15 '18 at 20:46
  • Also: explicitly naming your container can complicate the next run. You may want to add a `--rm` to the arguments to ensure you're not conflicting on container name. – benschumacher Feb 15 '18 at 20:46
  • @benschumacher, when I add an args after a point I see the following for my selenoid container logs: `2018/02/13 14:08:09 Loading configuration files...` `2018/02/13 14:08:09 /usr/bin/selenoid: browsers config: read error: open C:/Program Files/Git/etc/selenoid/browsers.json: no such file or directory` Could you please tell me, where I should use `--rm` option? right after run? (docker run --rm ...) – Maksim Gerasimenko Feb 15 '18 at 22:02
  • It looks like the selenoid container has bunch of [default arguments](https://github.com/aerokube/selenoid/blob/4cbf6cbc2460185ecc202720dc3e5b964236bd11/Dockerfile#L9) in the `CMD`. When you pass in arguments via the Docker command-line, you're overriding these entirely and thus losing the `-conf /etc/selenoid/browsers.json`, amongst others. – benschumacher Feb 15 '18 at 22:08
  • @benschumacher, I try without args: `docker.image('aerokube/selenoid').run('--name selenoid -p 4444:4444 -v C:/workspace/selenoid/:/etc/selenoid:ro -v C:/workspace/output/:/opt/selenoid/video/ -v //var/run/docker.sock:/var/run/docker.sock -e OVERRIDE_VIDEO_OUTPUT_DIR=/C/workspace/output/')` – Maksim Gerasimenko Feb 15 '18 at 23:18
  • Test broken: Please see selenoid logs: `2018/02/15 23:09:42 [0] [SERVICE_STARTUP_FAILED] [unknown] [start video container: create video container: Error response from daemon: invalid volume specification: 'C:/workspace/output/:/data:rw']` – Maksim Gerasimenko Feb 15 '18 at 23:18

1 Answers1

0

Take a look at Selenoid Dockerfile. Important lines are:

ENTRYPOINT ["/usr/bin/selenoid"]

CMD ["-listen", ":4444", "-conf", "/etc/selenoid/browsers.json", "-video-output-dir", "/opt/selenoid/video/"]

That means entrypoint command is always being run and everything inside CMD applies only if no args are passed explicitly. In your case you are adding your own arguments:

'-video-output-dir /output'

That means CMD section contents are not applied anymore. But -conf is a required argument which defaults to config/browsers.json, not /etc/selenoid/browsers.json. So correct solution is to add -conf /etc/selenoid/browsers.json to your expression.

vania-pooh
  • 2,933
  • 4
  • 24
  • 42
  • It is not working for me... I added -conf /etc/selenoid/browsers.json after point into run() section and still see empty docker ps output. – Maksim Gerasimenko Feb 16 '18 at 19:18
  • My last command is: `docker.image('aerokube/selenoid'). run('--name selenoid ' + '-p 4444:4444 ' + '-v C:/workspace/selenoid/:/etc/selenoid ' + '-v C:/workspace/output/:/opt/selenoid/video ' + '-v //var/run/docker.sock:/var/run/docker.sock ' + '-e "OVERRIDE_VIDEO_OUTPUT_DIR=C:/workspace/output/"', "-conf /etc/selenoid/browsers.json")` – Maksim Gerasimenko Feb 16 '18 at 19:20
  • This is because you are placing Selenoid arguments in wrong place. In `docker run` command they should be after image name. You are placing the before. There should be a separate method to pass application arguments, something like Cmd() or Args(). – vania-pooh Feb 19 '18 at 10:53