qemus / qemu-docker

QEMU in a Docker container.
MIT License
497 stars 59 forks source link

Ability to change internal NoVnc port #545

Closed fatez closed 5 months ago

fatez commented 5 months ago

Is your proposal related to a problem?

As the topic say,

Can you put a variable to be driven in the docker-compose to be able to change internal listening port of novnc? I ask because yesterday I wanted to try proxmox but at the end installation I had to reach port 8006 but it was already occupied by novnc.

Describe the solution you'd like.

.

Describe alternatives you've considered.

.

Additional context

No response

kroese commented 5 months ago

You can already do that in your compose file.

Just change

    ports:
      - 8006:8006

to

    ports:
      - 3333:8006

for example.

fatez commented 5 months ago

I can't. The internal port of proxmox is 8006. ( the same internal port of novnc).

I don't have to map the port but just change it.

In case try to virtualize proxmox and see if you can open the web page for login do proxmox

kroese commented 5 months ago

Internal ports of containers have no influence on eachother. You can have 100 containers with internal port 8006, as long as their external ports are different, it doesnt matter.

Are you sure you didnt swap left and right? Maybe you wrote 8006:3333 instead of 3333:8006?

fatez commented 5 months ago

we didn't understand each other.

Proxmox uses internal port 8006 for its werbserver. NoVNC uses internal port 8006 for its webserver.

I obviously cannot reach proxmox's webserver even changing the port on the cocker-compose.yaml by appointment is a redirect from 8005 external to 8006 internal.

There are 2 ports 8006 running internal.

Look at the screen :

https://i.postimg.cc/3Rc5fBmh/temp-Imagexo4l-Dm.avif

And this is my cocker-compose :

services:
  qemu:
    container_name: qemu-proxmox
    image: qemux/qemu-docker
    mac_address: d6:cb:ba:dc:de:03 
    networks:
      vlan:
        ipv4_address: 192.168.10.231
    environment:
      BOOT_MODE: "uefi"
      DISK_SIZE: "10G"
      DISK2_SIZE: "20G"
      DISK_FMT: "qcow2"
      RAM_SIZE: "8G"
      CPU_CORES: "8"
#      BOOT: "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-12.5.0-amd64-netinst.iso"
    volumes:
      - /media/BACKUP/ISO/os/proxmox-ve_8.2-1.iso:/boot.iso
      - ./storage:/storage
      - ./storage:/storage2
    devices:
      - /dev/kvm
      - /dev/bus/usb
    cap_add:
      - NET_ADMIN
    ports:
     - 8005:8006
    stop_grace_period: 2m
    restart: unless-stopped

networks:
  vlan:
    external: true

At the limit, if it doesn't take you too much time, can you try to virtualize proxmox yourself and tell me if it works for you (using macvlan?

kroese commented 5 months ago

Okay, now I understand you finally. I thought you were running this container on Proxmox (as the host OS). But its the opposite: you are running Proxmox inside the container. In that case I understand your problem.

I just did not expect anyone to do something like that haha. Because Proxmox is a system for running QEMU, so you will running QEMU inside QEMU? I am not even sure if that will work because it needs "nested virtualization" and not every CPU supports that.

In any case, you can solve it very easily, by downloading this file: https://github.com/qemus/qemu-docker/blob/master/web/nginx.conf Then changing the portnumber inside that file, and save it as custom.conf. And then put it in your compose file like this:

volumes:
  - /example/custom.conf:/etc/nginx/sites-enabled/web.conf

Thay way you can use another port for NoVNC.

fatez commented 5 months ago

Oh thank you very much! yes let's say i wanted to use proxmox in your qemu docker just to study it a bit and see if it suits me. your qemu project is so useful you have no idea how much i am using it.

thanks again

kroese commented 5 months ago

This is the line that you must edit:

    listen 8006 default_server;

its located at the top. Let me know if it worked!

fatez commented 5 months ago

I just tried but it doesn't work. I put port 8005 to nginx but I can't reach it. Come on, it doesn't matter. I will use virtualbox just to get proxmox going to study it a little bit

    volumes:
      - /media/BACKUP/ISO/os/proxmox-ve_8.2-1.iso:/boot.iso
      - ./storage:/storage
      - ./storage:/storage2
      - ./nginx.conf:/etc/nginx/sites-enabled/web.conf
GNU nano 7.2                                                               nginx.conf                                                                         
server {

    listen 80;
    listen 8005 default_server;
kroese commented 5 months ago

Ah.. I know why it is.. Because unless you use DHCP mode (DHCP=Y) then all traffic goes through a tunnel from the container to the VM. So we will need to make an exception:

  environment:
    HOST_PORTS: "8005"

That will make sure the traffic to port 8005 is not forwarded to the VM but the container. So it will fix noVNC, but because I also add an exception for 8006 automaticly, you will not be able to reach Proxmox on that port because the traffic is not redirected to the VM.

The simplest solution for you is to just enable DHCP mode. That way the container and VM will get different IP's and use a macvtap interface (so better performance and no tunnelling). That way they both can use port 8006 without problem because they are not sharing the same IP.

Its written here how to enable it:

https://github.com/qemus/qemu-docker#how-can-the-vm-acquire-an-ip-address-from-my-router

fatez commented 5 months ago

I thank you, I will try tomorrow and let you know