问题
I have this docker-compose configuration
version: '3'
services:
selenoid:
image: "aerokube/selenoid:latest"
container_name: selenoid
ports:
- "0.0.0.0:4444:4444"
networks:
- selenoid
volumes:
- ".:/etc/selenoid"
- "./target:/output"
- "/var/run/docker.sock:/var/run/docker.sock"
- "./target:/opt/selenoid/video"
environment:
- "OVERRIDE_VIDEO_OUTPUT_DIR=$PWD/target"
command: ["-limit", "10", "-conf", "/etc/selenoid/browsers.json", "-video-output-dir", "/opt/selenoid/video", "-container-network", "selenoid"]
selenoid-ui:
image: "aerokube/selenoid-ui:latest"
container_name: selenoid-ui
links:
- selenoid
ports:
- "8083:8080"
networks:
- selenoid
command: ["--selenoid-uri", "http://selenoid:4444"]
chrome_79.0:
image: "selenoid/vnc:chrome_79.0"
container_name: chrome_79.0
links:
- selenoid
- selenoid-ui
depends_on:
- selenoid
- selenoid-ui
networks:
- selenoid
volumes:
- "/dev/shm:/dev/shm"
sent:
image: "sent:1.0"
container_name: sent
links:
- selenoid
- selenoid-ui
depends_on:
- selenoid
- selenoid-ui
networks:
- selenoid
networks:
selenoid:
external:
name: selenoid
send is a container that runs TestNG tests, but looks like can not find localhost URL.
If I check the open ports I see this
chrome_79.0 /entrypoint.sh Up 4444/tcp
selenoid /usr/bin/selenoid -listen ... Up 0.0.0.0:4444->4444/tcp
selenoid-ui /selenoid-ui --selenoid-ur ... Up (health: starting) 0.0.0.0:8083->8080/tcp
And I can access localhost:4444 from outside, but even the container is in the same network can not access localhost.
Any ideas?
回答1:
Well, I little bit change your docker file and it works =)
- Remove chrome_79.0 and everything what is under
Because you can execute download chrome image directly:
docker pull selenoid/vnc:chrome_79.0
Remove all your "networks" (also from command section)
networks: -selenoid
and add instead (don't add in command section)
network_mode: bridge
i.e
image: "aerokube/selenoid:latest"
network_mode: bridge
.
.
.
image: "aerokube/selenoid-ui:latest"
network_mode: bridge
3.Before record video I suggest you to see how it works without recording...
Just change volumes section. I use Mac and in my situation it looks like
volumes:
- "$PWD:/etc/selenoid"
- "/var/run/docker.sock:/var/run/docker.sock"
- "$PWD:/opt/selenoid/logs"
4.Execute
docker-compose up
docker pull selenoid/vnc:chrome_79.0
5.See list of images and containers
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ef60d57bc743 aerokube/selenoid-ui:latest "/selenoid-ui --sele…" 2 hours ago Up 2 hours (healthy) 0.0.0.0:8083->8080/tcp selenoid-ui
05bf58b73f53 aerokube/selenoid:latest "/usr/bin/selenoid -…" 2 hours ago Up 2 hours 0.0.0.0:4444->4444/tcp selenoid
REPOSITORY TAG IMAGE ID CREATED SIZE
aerokube/selenoid-ui latest 71ad7fb4efa7 5 days ago 17.5MB
aerokube/selenoid latest b8f47d114751 11 days ago 16.3MB
selenoid/vnc chrome_65.0 dff07a4cfe6d 2 years ago 959MB
6.Open
http://localhost:8083
Fun
PS. If not working ask me directly.
来源:https://stackoverflow.com/questions/64973227/testng-docker-compose-can-not-find-localhost-url