如何在Docker中运行黄瓜/seleniumtesting?
我正在努力从Docker镜像运行我的黄瓜testing。
这是我的设置:
- 我使用XQuartz的OSX来运行X11会话
- 我使用Ubuntu 14 Vagrant映像进行开发,并将其转发给我的X11会话
- 我正在尝试使用Firefox来运行Docker镜像,该镜像将使用我的XQuartz会话进行显示
到目前为止,我设法使用以下设置启动Firefox:
# Dockerfile FROM ubuntu:14.04 RUN apt-get update && apt-get install -y firefox # Replace 1000 with something appropriate ;) RUN export uid=1000 gid=1000 && \ mkdir -p /home/developer && \ echo "developer:x:${uid}:${gid}:Developer,,,:/home/dev:/bin/bash" >> /etc/passwd && \ echo "developer:x:${uid}:" >> /etc/group && \ echo "developer ALL=(ALL) NOPASSWD: ALL" > /etc/sudoers.d/developer && \ chmod 0440 /etc/sudoers.d/developer && \ chown ${uid}:${gid} -R /home/developer USER developer ENV HOME /home/developer CMD /usr/bin/firefox
我可以从我的Vagrant机器启动Firefox --net=host
:
docker build -t firefox . docker run --net=host -ti --rm -e DISPLAY=$DISPLAY -v $HOME/.Xauthority:/home/developer/.Xauthority -v /tmp/.X11-unix:/tmp/.X11-unix:rw firefox:latest
但这并不理想,因为我无法在docker-compose.yml文件中将其他容器链接到我的机器上。 理想情况下,我想运行我的docker机器--net=host
像这样:
docker build -t firefox . docker run -ti --rm -e DISPLAY=$DISPLAY -v $HOME/.Xauthority:/home/developer/.Xauthority -v /tmp/.X11-unix:/tmp/.X11-unix:rw firefox:latest
但是我得到以下错误:
error: XDG_RUNTIME_DIR not set in the environment. Error: cannot open display: localhost:10.0
请帮忙 :)
您可以简单地使用elgalu / docker-selenium来避免处理已经解决的问题,并保持:
docker run --rm -ti --net=host --pid=host --name=grid \ -e SELENIUM_HUB_PORT=4444 -e TZ="US/Pacific" \ -v /dev/shm:/dev/shm --privileged elgalu/selenium
如果您需要诸如具有video录像的仪表板之类的高级function,或者需要实时预览,则可以使用Zalenium并从以下位置开始:
curl -sSL https://raw.githubusercontent.com/dosel/t/i/p | bash -s start -i