This is a How-To, to use NetBox with Docker on your local machine with WSL 2.
You need to install WSL 2 on your Windows machine with your PowerShell with wsl --install
or you can follow the instructions on how to set up a WSL development environment for your use specifications.
Make sure to follow the instructions, on how to use the WSL 2 based engine with Docker.
Follow the instructions step by step with Getting Started with NetBox Docker on your WSL terminal, as if it was a normal Linux environment.
After making sure that you can connect to your NetBox instance with your localhost, internal or WSL IP, then you could redirect an external IP (in this case, IP of your machine) with the internal IP of your WSL. (In case you´re setting the NetBox instance with public access).
netsh interface portproxy delete v4tov4 listenport=[your_port] listenaddress=0.0.0.0
wsl -u [WSL_user] hostname -I | Set-Variable -Name "IP"
$IP=$IP.replace(" ","")
netsh interface portproxy add v4tov4 listenport=[your_port] listenaddress=0.0.0.0 connectport=[your_port] connectaddress=$IP
powershell.exe -File "[path_to_script]\[name_of_script].ps1"
File cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.
Set-ExecutionPolicy unrestricted
Run the script again.
netsh interface portproxy show all
PS C:\> netsh interface portproxy show all
Listen on ipv4: Connect to ipv4:
Address Port Address Port
------- ----------- -------- -----------
0.0.0.0 [your_port] [WSL_IP] [your_port]
After that, make sure first that your NetBox Docker is running. You´ll be able to connect to your NetBox instance from a browser either with: localhost:[your_port], [internal_IP]:[your_port], [WSL_IP]:[your_port] or [external_IP]:[your_port].
In case you´re the only one who can access the NetBox instance from your machine only and no other host can, then you´ll need to create a new Firewall Inbound Rule to give access to other hosts to connect to your NetBox by running the following command:
New-NetFirewallRule -DisplayName "[choose_name]" -Direction Inbound -Action Allow -Protocol TCP -LocalPort [your_port]
or manually:
Windows Menu -> Settings -> Update & Security -> Windows Security -> Open Windows Security -> Firewall & network protection -> Advanced settings -> Inbound Rules -> New Rule -> Port -> Give only wished port -> Allow the connection -> Apply on all network locations and domains -> Give a name -> Finish
Congratulations, now others (on the same Network) will be able to connect to your NetBox instance.