blawar / nut

GNU General Public License v3.0
1.08k stars 189 forks source link

Allow to run through docker #466

Open felipecrs opened 1 year ago

felipecrs commented 1 year ago

For testing this before merging:

$ docker build --tag nut https://github.com/felipecrs/nut.git
$ docker run --rm -it --network=host --env=DISPLAY --volume=/tmp/.X11-unix:/tmp/.X11-unix --volume="$PWD:$PWD" --workdir="$PWD" --user=$(id -u):$(id -g) nut
felipecrs commented 1 year ago

@andrea-ap, replying to your comment here:

I just tried the two commands above and it worked just fine. Here is a quick demo:

https://github.com/blawar/nut/assets/29582865/9fbcd0ac-de38-4029-a4b2-37a012c344a6

Since you mentioned you are running with Docker Desktop, my recommendation is that you run this command through WSL2 and not through PowerShell/CMD for example.

andrea-ap commented 1 year ago

@andrea-ap, replying to your comment here:

I just tried the two commands above and it worked just fine. Here is a quick demo:

WindowsTerminal_pM5gcOy0wI.mp4 Since you mentioned you are running with Docker Desktop, my recommendation is that you run this command through WSL2 and not through PowerShell/CMD for example.


Hi, thank you for your quick reply. I have downloaded the code from the repository, I have already inserted the titledb folder, and inserted the key. I use winn1 and i installed ubuntu as subsystem of win11.I created image with: docker build -t nut . , and then I ran the command line: docker run --rm -it --network=host --env=DISPLAY --volume=/tmp/.X11-unix:/tmp/.X11-unix --volume= "$PWD:$PWD" --workdir="$PWD" --user=$(id -u):$(id -g) nut , the problem is that I don't reach my pc locally, using ip which tells me the nut server, but how can I proceed, do I have to change ip in the ubuntu instance as a win11 subnet, or do I have to create network in ducker?And not see connect usb? Thank you.

https://github.com/blawar/nut/assets/63066393/26e8dad2-2981-4eb5-90d9-1342f708e96f

felipecrs commented 1 year ago

Oh... I got your problem now. And I honestly don't know how you can overcome it.

andrea-ap commented 1 year ago

i solve with: sudo docker run --rm -it --network host --env=DISPLAY --volume=/tmp/.X11-unix:/tmp/.X11-unix --volume="$PWD:$PWD" --workdir="$PWD" --user=$(id -u):$(id -g) nut-server-mod:latest

felipecrs commented 1 year ago

What did you change exactly? Added sudo and removed the user?

andrea-ap commented 1 year ago

i wasn't reachable from outside, i changed --network=host to --network host , so i fixed it

andrea-ap commented 1 year ago

The --network host option is used to make programs inside the Docker container appear to be running on the host itself, from a network perspective³. This allows the container to have more network access than it can normally get.

Note that the host network driver only works on Linux hosts and is not supported on Docker Desktop for Mac, Docker Desktop for Windows, or Docker EE for Windows Server.

The --network option is used to specify the network to which the container should be connected during startup. Docker supports several network drivers, including bridge, host, overlay, ipvlan and macvlan. Each network driver has its own options and features.

felipecrs commented 1 year ago

That's funny. --network=host is the same as --network host, but glad it worked for you.