Check by connecting the Docker container application under development from a device other than a PC (smartphone)

Introduction

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. ** **

Ready to connect

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.

1. Check the IP of the relevant PC

Check the IP address with ipconfig image.png For Wi-Fi connection

2. Check the IP of the Docker application

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

3. Firewall permission settings

In addition to the firewall settings of the anti-virus software mentioned above, allow the port by Windows Defender.

  1. Open the Windows Defender firewall settings screen and create a new rule. image.png

  2. Select a port image.png

  3. Select TCP and specify a specific local port Since we are allowing multiple applications here, we have specified three ports. image.png

  4. Allow connection image.png

  5. Here, the rules allow everything (change depending on the situation) image.png

  6. Save As image.png

4. Port forwarding settings

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 image.png

To erase it: interface portproxy reset

5. Confirmation

After launching the Docker container http://192.168.11.6:3000/ You can see the application by connecting to other than the local PC.

Summary

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.

reference

https://gakuya.work/docker-for-windows-smartphone-access/

Recommended Posts

Check by connecting the Docker container application under development from a device other than a PC (smartphone)
Check the contents by docker pull from ECR and start the container
How to check the WEB application created in the PC development environment on your smartphone
Run x11 apps in a Docker container (supports network access from the container)
How to connect to lcalhost from your smartphone and use the app under development
Learn while making a WEB server Introduction to WEB application development from the basics
How to build a Jenkins server with a Docker container on CentOS 7 of VirtualBox and access the Jenkins server from a local PC