rancher / old-vm

(OBSOLETE) Package and Run Virtual Machines as Docker Containers
Apache License 2.0
645 stars 133 forks source link

VNC console link not shown in GUI #88

Closed candlerb closed 5 years ago

candlerb commented 6 years ago

(This is with docker 17.09.0~ce-0~ubuntu under Ubuntu 16.04)

I start RancherVM management GUI as per instructions - except on a different port since I'm already using 8080 for rancher:

docker run -v /var/run:/var/run -p 8123:80 -v /var/lib/rancher/vm:/vm rancher/ranchervm

Then I connect to <dockerhost>:8123, click on "create instance", and the instance is created fine. However in the instance listing, there is no option to connect to its console; only "Stop" is offered.

image

But the article shows that I should see a "Console" link for running containers:

documentation image

If I look inside the container:

# docker exec -it reverent_heisenberg bash
root@i-775071e0:/# ps auxwww
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  6.1 17.9 1906472 275416 ?      Ssl  18:37   2:31 qemu-system-x86_64 -enable-kvm -vnc unix:/ranchervm/vm/ac20250faf208407634ba92d8af5055df4ec1662c5310b82952a43709f6b339c/vnc -drive file=/image/sda.qcow2,if=none,id=drive-disk0,format=qcow2 -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x6,drive=drive-disk0,id=virtio-disk0,bootindex=1 -netdev bridge,br=br0,id=net0 -device virtio-net-pci,netdev=net0,mac=02:42:ac:11:00:06 -m 512m -smp 1
root        36  0.0  0.0  28208  1512 ?        S    18:37   0:00 dnsmasq
root       104  0.0  0.2  18176  3160 pts/0    Ss+  19:13   0:00 bash
root       151  2.5  0.1  18168  2996 pts/1    Ss   19:18   0:00 bash
root       165  0.0  0.1  15568  1904 pts/1    R+   19:18   0:00 ps auxwww
root@i-775071e0:/# ls -l /ranchervm/vm/ac20250faf208407634ba92d8af5055df4ec1662c5310b82952a43709f6b339c/vnc
srwxr-xr-x 1 root root 0 Nov 19 18:37 /ranchervm/vm/ac20250faf208407634ba92d8af5055df4ec1662c5310b82952a43709f6b339c/vnc

... I see that the VNC socket is being written under a path under /ranchervm. However, this path is not accessible to the management container as far as I can tell.

# docker container inspect reverent_heisenberg
...
        "Mounts": [
            {
                "Type": "volume",
                "Name": "4e7ea731ea95dab78cf8345b2f45c1e7743170cb447b27845f98b8aed2ed7cbb",
                "Source": "/var/lib/docker/volumes/4e7ea731ea95dab78cf8345b2f45c1e7743170cb447b27845f98b8aed2ed7cbb/_data",
                "Destination": "/ranchervm",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            },
            {
                "Type": "volume",
                "Name": "a13f195bf8ef0413a79f709db0afb3dabf62b83b4bdcde5e36d8677991d160ae",
                "Source": "/var/lib/docker/volumes/a13f195bf8ef0413a79f709db0afb3dabf62b83b4bdcde5e36d8677991d160ae/_data",
                "Destination": "/image",
                "Driver": "local",
                "Mode": "",
                "RW": true,
                "Propagation": ""
            },
            {
                "Type": "bind",
                "Source": "/var/run",
                "Destination": "/var/run",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            },
            {
                "Type": "bind",
                "Source": "/var/lib/rancher/vm",
                "Destination": "/vm",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],

That is, the path /ranchervm is in its own, randomly-named docker volume. The directory /vm, which is shared between the management container and the VM container (and is /var/lib/rancher/vm on the host), is empty.

Any suggestions for where I should look?

candlerb commented 6 years ago

I think there's a mismatch between where the mgmt container wants things mounted, and the VM rancher/vm-rancheros container.

Looking at the CGI, the VM container is started using volumes_from. But if I manually start the VM container with the shared volume mounted under /ranchervm/vm, it works:

docker run -e "RANCHER_VM=true" --cap-add NET_ADMIN -v \
    /var/lib/rancher/vm:/ranchervm/vm --device /dev/kvm:/dev/kvm \
    --device /dev/net/tun:/dev/net/tun rancher/vm-rancheros
candlerb commented 6 years ago

OK, I see what the problem is - the published VM images are outdated, and do not reflect what's in the git repository.

In git, image/base/startvm has

    VNC="-vnc unix:/vm/$DOCKERID/vnc"
    echo VNC server will listen on Unix socket /vm/$DOCKERID/vnc

and in image/base/Dockerfile this is copied to /var/lib/rancher/startvm

But in the running container started from rancher/vm-rancher on docker hub, /var/lib/rancher/startvm says:

    VNC="-vnc unix:/ranchervm/vm/$DOCKERID/vnc"
    echo VNC server will listen on Unix socket /ranchervm/vm/$DOCKERID/vnc

I think just pushing rebuilt images would fix this. (An opportunity to update vm-ubuntu to 16.04 as well...)

LLParse commented 5 years ago

VNC console support was refactored as part of the migration to Kubernetes. There is also a new UI with clearly visible console/novnc button.