例如,我想从dockerhub运行一个mongodb docker映像
mongo:3.6
或
mongo:4.1
在Azure Web应用程序中,但我无法从外部访问它。
根据Azure日志,docker容器可以正常启动,日志显示:
docker run -d -p 29794:27017 --name mytestapp -e WEBSITE_SITE_NAME=mytestapp -e WEBSITE_AUTH_ENABLED=False -e PORT=27017 -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=mytestappurl -e WEBSITE_INSTANCE_ID=xxx -e HTTP_LOGGING_ENABLED=1 mongo:4.1
2019-06-15 19:42:49.831 INFO - Container mytestapp for site mytestapp initialized successfully and is ready to serve requests.
据我所知
Azure Web App Service only supports port 80 and 443 for inbound traffic
并将内部端口(在mongodb:27017的情况下)映射到端口80或443,具体取决于SSL与否。
当我通过浏览器和端口80访问我的web应用程序时,我会收到消息
It looks like you are trying to access MongoDB over HTTP on the native driver port.
也就是说,该服务以某种方式是可访问的,正在端口80上等待请求,但是当我尝试通过mongo连接时,例如:
mongo -host mytestappurl -port "80" -username "root" -passwort "myrootpw" --verbose
我明白了
creating new connection to:mytestappurl:80
D NETWORK [js] connected to server to:mytestappurl:80
I NETWORK [js] recv(): message msgLen 1347703880 is invalid. Min 16 Max: 48000000
等等。我还试图在Azure应用程序设置中设置密钥/值对网站端口=27017,但没有成功。相同的安装程序在本地运行良好,我可以按预期访问mongodb。