docker creates appium container and connects to night god simulator

Find mirror

Use the docker search command to search the appium image

docker search appium

Pull mirror

docker pull appium/appium

When pulling the image, I encountered an error Could not reach any registry endpoint. Some people said that this may be caused by the docker version is too low. Due to the limited version of docker supported by Centos6, I changed to Centos7 to continue pulling. CentOS7 install docker, please poke here-> "Installing Docker under Centos7 (detailed installation tutorial)"
There is another problem. Using DaoCloud to configure the image accelerator to pull appium is really a slow batch. Finally, Alibaba Cloud image accelerator is configured. To configure Alibaba Cloud acceleration, please poke here- > "Install docker under CentOS and use Alibaba Cloud image accelerator"

Start the container

Start the appium container and map the port to 4723 with the name appium_1

docker run --privileged -d -p 4723:4723 --name appium_1 appium/appium

# --privileged:使用该参数,容器内的root拥有真正的root权限,否则容器内的root只是外部的一个普通用户权限
# -d:以分离模式启动容器,分离模式指的是在后台运行,而前景模式指的是在前台运行。默认分离模式设置为False
# -p:指定要映射的ip和端口。支持的格式有:hostPort:containerPort,ip:hostPort:containerPort,ip::containerPort。这里用的是第一种:4723:4723,指的是将本地(centos7)的5000端口映射到容器的5000端口
# --name:为容器指定一个名字

View the running status of the container

docker ps

Install jdk

I have installed jdk on Centos7, if not installed, please poke here- > "Centos7 install JDK8 and environment configuration"

Install adb

If not installed, please poke here- > "centos7 install adb"

Simulator settings

Change connection method

Change the usb connection method of night god mode to tcpip

C:\Users\beck
λ adb devices
List of devices attached
127.0.0.1:62025 device

C:\Users\beck
λ adb -s 127.0.0.1:62025 tcpip 6666
restarting in TCP mode port: 6666

Change bridge

Open the system settings-> property settings-> network settings, check to open the network bridge mode, then you need to install a plug-in, after installation, select static IP, because my emulator is installed on the windows system ip is 192.168.0.101, here I set to 192.168.0.126, set the gateway 192.168.0.1, click save settings, restart the simulator

After restarting, turn off the WLAN, turn it on again, click settings, check the ip address, you can see the ip becomes 192.168.0.102

docker connection emulator

docker exec -it appium_1 adb connect 192.168.0.102:6666

# docker exec:在运行的容器中执行命令
# -i:即使没有附加也保持STDIN打开
# -t:分配一个伪终端

See connected to 192.168.0.102:6666, indicating that the connection is successful

Reference article

"" Docker combat article "python docker-create appium container and set appium container connection Android emulator (31)"
"Docker: Docker Appium mirror connection night Android god emulator, and handle connection refused exception"
"Docker exec command"

Guess you like

Origin www.cnblogs.com/my_captain/p/12738964.html