During development, it was necessary to check the application launched with Docker from a place other than the local PC (smartphone), so include personal notes. ** * Settings are made in a Windows environment. ** **
As a premise, the terminals must be connected to the same network. Also, depending on the environment, it may be necessary to make settings such as temporarily disabling the firewall of anti-virus software or allowing a specific port. After making the settings in advance, execute the following procedure.
Check the IP address with ipconfig For Wi-Fi connection
The IP of the Docker application varies depending on the environment [^ 1], but this time it connects to the Rails application, so from the startup command rails s -b 0.0.0.0
, the port forwarding destination will also be 0.0.0.0
.
(In this case, you do not need to set 4. Port forwarding described later)
[^ 1]: 192.168.99.100 is the default for docker-machine
In addition to the firewall settings of the anti-virus software mentioned above, allow the port by Windows Defender.
Open the Windows Defender firewall settings screen and create a new rule.
Select a port
Select TCP and specify a specific local port Since we are allowing multiple applications here, we have specified three ports.
Allow connection
Here, the rules allow everything (change depending on the situation)
Save As
If the IP of Docker is a specific IP address, it is necessary to port forward to the smartphone => PC => Docker container, so make the following settings by netsh.
Command prompt Open with administrator privileges and execute the netsh
command.
Then execute the following command to perform port forwarding.
interface portproxy add v4tov4 listenport=3000 listenaddress=192.168.11.6 connectport=3000 connectaddress=192.168.99.100
The above is
interface portproxy add v4tov4 listenport = {listening port of local PC} listenaddress = {IP address of local PC} connectport = {port of Docker} connectaddress = {IP address of Docker}
It will be.
If there are multiple, execute multiple times. When specifying a range, specify as 3000-3100
.
To check the settings below
interface portproxy show v4tov4
To erase it:
interface portproxy reset
After launching the Docker container
http://192.168.11.6:3000/
You can see the application by connecting to other than the local PC.
I think it is a merit to be able to check the behavior peculiar to smartphones on the spot without the hassle of raising it to the STG environment, so I hope it will be helpful.
https://gakuya.work/docker-for-windows-smartphone-access/
Recommended Posts