我想使用Docker Java客户端创建和运行Docker。我希望能像这样运行:
docker run -d -p 4444:4444 --name selenium-hub selenium/hub:2.53.0
如何在docker-java客户端上实现此命令?以下是我目前的代码:
CreateContainerResponse response = dockerClient.createContainerCmd("selenium/hub")
.withName(name)
.exec();
实际上我不知道如何指定-d(以后台运行)和-p参数。请帮帮我,抱歉我是Docker的新手。
ExposedPort tcp4444 = ExposedPort.tcp(4444); Ports portBindings = new Ports(); portBindings.bind(tcp4444,Ports.Binding.bindPort(4444)); CreateContainerResponse response = dockerClient. createContainerCmd("selenium/hub") .withName(name) .withExposedPorts(tcp4444) .exec();
- HendrionewithPortBindings
已从创建容器命令中移除。你知道新的语法吗? - Noah Solomon