Skip to content

Instantly share code, notes, and snippets.

@ziouf
Last active June 5, 2018 09:31
Show Gist options
  • Save ziouf/68108ca6b4406ef8b0c1b4bfcbc87d54 to your computer and use it in GitHub Desktop.
Save ziouf/68108ca6b4406ef8b0c1b4bfcbc87d54 to your computer and use it in GitHub Desktop.
Workarround to allow downloaded file sharing between jenkins-slave and selenium containers

Docker-compose : Jenkins + Selenium grid

Why ?

When using Jenkins and Selenium grid on a Docker stack components are isolated. So it could be quite hard to find and read downloaded file by a test case.

The workarround is to override selenium images to set user id equals to jenkins user id and share /dev/shm mount point between containers.

Usage

Tu use this Gist you must set your selenium test cases to check downloaded files located in /dev/shm/

docker-compose -f docker-compose up --bulid
version: '3'
services:
jenkins:
image: jenkinsci/slave
volumes:
- /dev/shm:/dev/shm:rw
selenium-hub:
image: mycompany/selenium-hub
build:
context: .
dockerfile: dockerfile
build-args:
- image=selenium/hub
- version=latest
environment:
- "GRID_TIMEOUT=60000"
volumes:
- /dev/shm:/dev/shm:rw
networks:
- selenium
selenium-chrome:
image: mycompany/selenium-node-chrome
build:
context: .
dockerfile: dockerfile
build-args:
- image=selenium/node-chrome-debug
- version:latest
environment:
- "HUB_HOST=selenium-hub"
- "HUB_PORT_4444_TCP_ADDR=selenium-hub"
volumes:
- "/dev/shm:/home/seluser/Downloads:rw"
networks:
- selenium
networks:
selenium:
ARG version=latest
ARG image=selenium/hub
FROM ${image}:${version}
USER root
RUN usermod -u 10000 seluser
RUN chown -R seluser:seluser /opt/selenium
USER seluser
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment