### 创建selenium grid(网络必须使用net,不能使用桥接)
# https://github.com/SeleniumHQ/docker-selenium/blob/trunk/docker-compose-v3.yml
docker network create selenium-grid
docker run -d -p 4442-4444:4442-4444 --net selenium-grid --name selenium-hub selenium/hub:4.4.0-20220812
docker run -d --net selenium-grid -e SE_EVENT_BUS_HOST=selenium-hub \
--name selenium-node-chrome-1 \
--shm-size="2g" \
-p 7901:7900 \
-e SE_EVENT_BUS_PUBLISH_PORT=4442 \
-e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 \
selenium/node-chrome:4.4.0-20220812
docker run -d --net selenium-grid -e SE_EVENT_BUS_HOST=selenium-hub \
--name selenium-node-chrome-2 \
--shm-size="2g" \
-p 7902:7900 \
-e SE_EVENT_BUS_PUBLISH_PORT=4442 \
-e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 \
selenium/node-chrome:4.4.0-20220812
docker run -d --net selenium-grid -e SE_EVENT_BUS_HOST=selenium-hub \
--name selenium-node-chrome-3 \
--shm-size="2g" \
-p 7903:7900 \
-e SE_EVENT_BUS_PUBLISH_PORT=4442 \
-e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 \
selenium/node-chrome:4.4.0-20220812
docker run -d --net selenium-grid -e SE_EVENT_BUS_HOST=selenium-hub \
--name selenium-node-chrome-4 \
--shm-size="2g" \
-p 7904:7900 \
-e SE_EVENT_BUS_PUBLISH_PORT=4442 \
-e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 \
selenium/node-chrome:4.4.0-20220812
docker run -d --net selenium-grid -e SE_EVENT_BUS_HOST=selenium-hub \
--name selenium-node-edge-1 \
--shm-size="2g" \
-p 7911:7900 \
-e SE_EVENT_BUS_PUBLISH_PORT=4442 \
-e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 \
selenium/node-edge:4.4.0-20220812
docker run -d --net selenium-grid -e SE_EVENT_BUS_HOST=selenium-hub \
--name selenium-node-firefox-1 \
--shm-size="2g" \
-p 7921:7900 \
-e SE_EVENT_BUS_PUBLISH_PORT=4442 \
-e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 \
selenium/node-firefox:4.4.0-20220812
### 查看状态
http://10.11.25.56:4444/status
http://10.11.25.56:4444/ui
http://10.11.25.56:7903
# 密码: secret
### 停止容器并删除
docker ps |grep selenium|awk '{print "docker stop "$1"; docker rm "$1";"}'|sh
### 连接vnc教程
https://www.cnblogs.com/superhin/p/13860955.html
# vnc app
https://www.realvnc.com/en/connect/download/viewer/
### standalone模式
docker run -d -p 4444:4444 --shm-size="2g" selenium/standalone-chrome:4.4.0-20220812
### 启动失败原因
# pom里太多依赖
### 官方文档
https://github.com/SeleniumHQ/docker-selenium
https://www.selenium.dev/zh-cn/documentation/webdriver/
标签:教程,--,BUS,selenium,docker,EVENT,SE
From: https://www.cnblogs.com/chenzechao/p/16637117.html