unable to view the playwright docker test execution through VNC viewer - playwright

I am trying to execute the script in mcr.microsoft.com/playwright:bionic docker container .
I have exposed the port 5900 as shown below but unable to connect to host when i tried with the vnc viewer localhost:5900. I can able to view other docker container such as selenium/standalone-chrome execution through vnc viewer but not playwright !
How can I view the playwright docker container test execution ? is any other way that i can see the test execution live ? Any help would be much appreciated !
docker run --name playwright1 -it --rm --ipc=host --cap-add=SYS_ADMIN -u root -p 5900:5900 -v $(pwd):/src -v /home/Automation/:/root/.m2 mcr.microsoft.com/playwright:bionic &

You have exposed the port, but is a vnc server & x-server like Xvfb running inside the container? Opening the port won't accomplish anything if there isn't anything listening on the other side.
This question has great information on how to setup both xvfb and x11vnc to achieve what you are trying to do. Just add FROM mcr.microsoft.com/playwright:focal to the top of your own Dockerfile, followed by the stuff in the linked answer.

Related

How can I setup a network connection for a Docker container running Universal Robots simulator?

I'm using Docker to create a container that is running a Universal Robots simulator with the official image using the following command:
docker run --rm -it -p 5900:5900 -p 6080:6080 universalrobots/ursim_e-series
In the simulator's settings menu it shows that it isn't connected to a network. I think the container isn't receiving a network connection. When I change the command to...
docker run --rm -it -net host universalrobots/ursim_e-series
I'm unable to access the web interface for PolyScope through the prompted url:
http://192.168.65.4:6080/vnc.html?host=192.168.65.4&port=6080
I feel like I'm missing something fundamental to docker containers but can't seem to resolve it.

The URL is not working after running the container in Docker Toolbox

I pulled the docker container from the docker hub. After running the container, it gave me two links which should direct me to my desired page but both links show "the site can't be reached. I am using the following command: docker run 'name of the container'
I am working in the Docker toolbox in windows 10 home version.
Any help is highly appreciated
few Things first, docker hub has images that you pull and then using those images you start a container.
to start a container using the command - docker run -p 8080:8080 -d <image-name>
here -d is for a detached container so that it does not stop with the shell.
and -p is port that you want to be linked to your localhost port.
Your container would be in running state. check by the command docker ps.
Hope this helps. First answer on StackOverflow.

Pycharm use Docker Container Python as Remote Interpreter

I am trying to use the python in a docker container on a remote machine as the interpreter in Pycharm. Since that is a mouthful, here is a diagram:
There is a Jupyter Notebook running in the container, which I am able to connect to through my local browser (although this is just for testing the connection). The command I am using to launch the Docker container is
docker run --runtime=nvidia -it --rm --shm-size=2g -v /home/timo/storage:/storage -v /etc/passwd:/etc/passwd -v /etc/group:/etc/group --ulimit memlock=-1 -p 8888:8888 -p 7722:22 --ipc=host latest:latest
I can forward the port 8888 which the Jupyter notebook is running on with ssh -L 8888:0.0.0.0:8888 BBB.BBB.BBB.BBB and thus use it on the local machine. But I don't much like using Jupyter for developing and would like to use the Python interpreter in the Docker Container in Pycharm.
When I select "Add Python Interpreter" in Pycharm, I get the following options:
The documentation for Pycharm suggests using the "Add Python Interpreter/Docker" tool which looks like this:
However the documentation doesn't say how to set up the Docker container and the connections if the Docker is on a remote machine.
So my questions are: should I use a Unix or a TCP socket to connect to my remote docker? Or should I somehow forward all the relevant ports from the container and use the "SSH Interpreter" option? And if so, how do I set this all up? Am I setting up my Docker Container properly in the first place?
I think I have trawled through every forum and online resource, over the last two days, but have not come any closer to getting this to work. I have also tried to get this to work in Spyder, but to no avail either. So any advice is very appreciated!
Many thanks!
Thank you for depicting the dilemma so poignantly and clearly in your cartoon :-). My colleague and I were trying to do something similar and what ultimately worked beautifully was creating an SSH config directly to the Docker container jumping from the remote machine, and then setting it as a remote SSH interpreter so that pycharm doesn't even realize it's a Docker container. It also works well for vscode.
set up ssh service in docker container (subset of steps in https://dev.to/s1ntaxe770r/how-to-setup-ssh-within-a-docker-container-i5i, port22 stuff wasn't needed)
docker exec -it <container> bash: create admin interactive prompt for docker
apt-get install openssh-server
service ssh start
confirm with service ssh status -> * sshd is running
determine IP and test SSHing from remote machine into container (adapted from https://phoenixnap.com/kb/how-to-ssh-into-docker-container, steps 2 and 3)
from normal command prompt on remote machine (not within container): docker inspect -f "{{ .NetworkSettings.IPAddress }}" <container> to get container IP
test: ping -c 3 <container_ip>
ssh: ssh <container_ip>; should drop you into the container as your user; however, requires container to be configured properly (docker run cmd has -v /etc/passwd:/etc/passwd:ro \ etc.). It may ask for a password. note: if you do this for a different container later that is assigned the same IP, you will get a warning and may need to delete the previous key from known_hosts; just follow the instructions in the warning.
test SSH from local machine
if you don't have it set up already, set up passwordless ssh key-based authentication to the remote machine with the docker container
make SSH command that uses your remote machine as a jump server to the container: ssh -J <remote_machine> <container_ip>, as described in https://wiki.gentoo.org/wiki/SSH_jump_host; if successful you should drop into the container just as you did from the remote machine
save this setup in your ~/.ssh/config; follow the ProxyJump Example from https://wiki.gentoo.org/wiki/SSH_jump_host
test config with ssh <container_host_name_defined_in_ssh_config>; should also drop you into interactive container
configure pycharm (or vscode or any IDE that accepts remote SSH interpreter)
Preferences -> Project -> Python Interpreter -> Add -> SSH Interpreter -> New server configuration
host: <container_host_name_defined_in_ssh_config>
port: 22
username: <username_on_remote_server>
select interpreter, can navigate using the folder icon, which will walk you through paths within the docker, or you can enter the result of which python from the container
follow pycharm prompts

Cannot access web on running docker containers

I have two containers, wds and apache. Both of them are running and have clear logs. I also checked if apache is running inside apache container and It is. My problem is that if I try to connect at localhost:80 which is the port that apache container listents to, I get only ERR_TIMED_OUT. Can you point me in which direction to look ? Containers were builded succesfully, no errors in logs, apache is running. I don't know where to look.
did you expose the port in Dockerfile and used -p 80:80 while using docker run command?
There is a specific logic to be followed while running or interacting with containers.
I do not know what commands or arguments you want to use so I will put an example here with basic explanation assuming you want to run a container with exposed port 80 in terminal interactive
docker run [container ID] -ti -p 80:80 /bin/bash
used commands:
-t tty - allocate a terminal so you can directly interact with the docker command
-i - interactive - connects STDIN to the allocated terminal. Any command you enter after this will go to the terminal.
-p - binds port
https://docs.docker.com/network/host/
https://docs.docker.com/engine/reference/run/

Docker in Docker: Port Mapping

I have found a similar thread, but failed to get it to work. So, the use case is
I start a container on my Linux host
docker run -i -t --privileged -p 8080:2375 mattgruter/doubledocker
When in that container, I want to start another one with GAE SDK devserver running.
At that, I need to access a running app from the host system browser.
When I start a container in the container as
docker run -i -t -p 2375:8080 image/name
I get an error saying that 2375 port is in use. I start the app, and can curl 0.0.0.0:8080 when inside both containers (when using another port 8080:8080 for example) but cannot preview the app from the host system, since lohalhost:8080 listens to 2375 port in the first container, and that port cannot be used when launching the second container.
I'm able to do that using the image jpetazzo/dind. The test I have done and worked (as an example):
From my host machine I run the container with docker installed:
docker run --privileged -t -i --rm -e LOG=file -p 18080:8080
jpetazzo/dind
Then inside the container I've pulled nginx image and run it with
docker run -d -p 8080:80 nginx
And from the host environment I can browse the nginx welcome page with http://localhost:18080
With the image you were using (mattgruter/doubledocker) I have some problem running it (something related to log attach).

Resources