Search code examples
dockervncvnc-viewer

docker vnc 2nd time connect issue


i have created a docker image. Then i run it with command docker run -d -p 5901:5901 -p 2222:22 dockerImageName. Docker runs fine. After this i connect to vnc using 0.0.0.0:5901. It connects properly and i get a GUI.

Now i stop the docker using docker stop containerId. Now if i try to rerun the container using command docker start containerId, docker comes up but when i try to connect to vnc using 0.0.0.0:5901, it says connect closed unexpectedly

I am using this image https://hub.docker.com/r/thyrlian/android-sdk-vnc/


Solution

  • It looks like the VNC server in the thyrlian/android-sdk-vnc image doesn't start the same way a second time because a lock file gets left behind when the container stops.

    If I create and start a container from that image, here's what vncserver-stderr.log shows.

    ▸ ~ docker run -d -p 5901:5901 -p 2222:22 --name android-sdk-vnc thyrlian/android-sdk-vnc
    212b6de3d3ee71f221e7e190baaf650b779cf351a9c4654db19ef3402cdaa86f
    ▸ ~ docker exec android-sdk-vnc cat /var/log/supervisord/vncserver-stderr.log
    xauth:  file /root/.Xauthority does not exist
    
    New 'X' desktop is 212b6de3d3ee:1
    
    Creating default startup script /root/.vnc/xstartup
    Starting applications specified in /root/.vnc/xstartup
    Log file is /root/.vnc/212b6de3d3ee:1.log
    

    After stopping and starting the same container, here's what the log shows.

    ▸ ~ docker stop android-sdk-vnc
    android-sdk-vnc
    ▸ ~ docker start android-sdk-vnc
    android-sdk-vnc
    ▸ ~ docker exec -it android-sdk-vnc cat /var/log/supervisord/vncserver-stderr.log
    xauth:  file /root/.Xauthority does not exist
    
    New 'X' desktop is 212b6de3d3ee:1
    
    Creating default startup script /root/.vnc/xstartup
    Starting applications specified in /root/.vnc/xstartup
    Log file is /root/.vnc/212b6de3d3ee:1.log
    
    
    Warning: 212b6de3d3ee:1 is taken because of /tmp/.X1-lock
    Remove this file if there is no X server 212b6de3d3ee:1
    
    New 'X' desktop is 212b6de3d3ee:2
    
    Starting applications specified in /root/.vnc/xstartup
    Log file is /root/.vnc/212b6de3d3ee:2.log
    

    I'm not familiar with this VNC server, but I'm guessing the lock file at /tmp/.X1-lock is preventing it from running the same way as the first time.

    I suggest filing an issue in the source GitHub repository. You can find it on the Docker Hub page for thyrlian/android-sdk-vnc, on the side under Source Repository.