我正在使用 Windows 与 Docker 一起运行 Selenium Grid 4(动态网格)。这是我关注的文档 https://github.com/SeleniumHQ/docker-selenium。我有一个 docker-compose 文件和一个 config.toml 文件,它们都位于我的 Documents 目录中。为了方便起见,我在下面附上了它。
码头工人-compose.yml
# To execute this docker-compose yml file use `docker-compose -f docker-compose-v3-dynamic-grid.yml up`
# Add the `-d` flag at the end for detached execution
# To stop the execution, hit Ctrl+C, and then `docker-compose -f docker-compose-v3-dynamic-grid.yml down`
version: "3"
services:
node-docker:
image: selenium/node-docker:4.1.2-20220208
volumes:
- ./assets:/opt/selenium/assets
- ./NodeDocker/config.toml:/opt/bin/config.toml
depends_on:
- selenium-hub
environment:
- SE_EVENT_BUS_HOST=selenium-hub
- SE_EVENT_BUS_PUBLISH_PORT=4442
- SE_EVENT_BUS_SUBSCRIBE_PORT=4443
selenium-hub:
image: selenium/hub:4.1.2-20220208
container_name: selenium-hub
ports:
- "4442:4442"
- "4443:4443"
- "4444:4444"
配置文件
[docker]
# Configs have a mapping between the Docker image to use and the capabilities that need to be matched to
# start a container with the given image.
configs = [
"selenium/standalone-firefox:4.1.2-20220208", "{\"browserName\": \"firefox\"}",
"selenium/standalone-chrome:4.1.2-20220208", "{\"browserName\": \"chrome\"}",
"selenium/standalone-edge:4.1.2-20220208", "{\"browserName\": \"MicrosoftEdge\"}"
]
# URL for connecting to the docker daemon
# Most simple approach, leave it as http://127.0.0.1:2375, and mount /var/run/docker.sock.
# 127.0.0.1 is used because interally the container uses socat when /var/run/docker.sock is mounted
# If var/run/docker.sock is not mounted:
# Windows: make sure Docker Desktop exposes the daemon via tcp, and use http://host.docker.internal:2375.
# macOS: install socat and run the following command, socat -4 TCP-LISTEN:2375,fork UNIX-CONNECT:/var/run/docker.sock,
# then use http://host.docker.internal:2375.
# Linux: varies from machine to machine, please mount /var/run/docker.sock. If this does not work, please create an issue.
url = "http://127.0.0.1:2375"
# Docker image used for video recording
video-image = "selenium/video:ffmpeg-4.3.1-20220208"
# Uncomment the following section if you are running the node on a separate VM
# Fill out the placeholders with appropriate values
#[server]
#host = <ip-from-node-machine>
#port = <port-from-node-machine>
当我从它们都所在的“文档”目录中的 powershell 或 windows 命令行执行以下命令时,出现错误:
docker-compose up
PS C:\users\antwan.maddox\Documents> docker-compose up
WARNING: Found multiple config files with supported names: docker-compose.yml, docker-compose.yaml
WARNING: Using docker-compose.yml
Creating network "documents_default" with the default driver
Creating selenium-hub ... done
Creating documents_node-docker_1 ... error
ERROR: for documents_node-docker_1 Cannot start service node-docker: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/host_mnt/c/Users/antwan.maddox/Documents/NodeDocker/config.toml\\\" to rootfs \\\"/var/lib/docker/overlay2/6e6f26f815f567ae05e777c7d05e3139aeb09a3bd399355ae5fc0dce858bfe6d/merged\\\" at \\\"/var/lib/docker/overlay2/6e6f26f815f567ae05e777c7d05e3139aeb09a3bd399355ae5fc0dce858bfe6d/merged/opt/bin/config.toml\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: for node-docker Cannot start service node-docker: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"rootfs_linux.go:58: mounting \\\"/host_mnt/c/Users/antwan.maddox/Documents/NodeDocker/config.toml\\\" to rootfs \\\"/var/lib/docker/overlay2/6e6f26f815f567ae05e777c7d05e3139aeb09a3bd399355ae5fc0dce858bfe6d/merged\\\" at \\\"/var/lib/docker/overlay2/6e6f26f815f567ae05e777c7d05e3139aeb09a3bd399355ae5fc0dce858bfe6d/merged/opt/bin/config.toml\\\" caused \\\"not a directory\\\"\"": unknown: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type
ERROR: Encountered errors while bringing up the project.
请帮助我了解我在遵循文档时缺少的内容,其中确实提到了有关安装资产的内容。我不确定这意味着什么,但我使用的是 Windows 机器。我只想运行此处显示的示例https://www.youtube.com/watch?v=nEyo8cNhZb4&t=391s