本文介绍了如何在azure中进行端口映射 - (如何在创建docker镜像时在Azure上运行docker等效命令)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我想在Azure容器上创建配置数据库泊坞窗图像。显然,配置数据库默认使用3000端口来运行应用程序。因此,我使用以下命令创建我的泊坞窗图像

I want to create a metabase docker image on Azure container. Apparently metabase uses 3000 port by default to run the application. Hence I used following command to create my docker image

`az容器创建--resource-group MyResourceGroup --name配置数据库 - 图像配置数据库/配置数据库 - -dns-name-label mb_app --ports 3000 --environment-variables MB_DB_TYPE = postgres MB_DB_DBNAME = metabase_azure_staging MB_DB_PORT = 5432 MB_DB_USER = abc MB_DB_PASS = abc_password
MB_DB_HOST = my_host.com`



我希望我的应用程序在端口80上侦听,因此我想将此端口映射到3000 t0 80.在docker中的等效命令将是 

`docker run -d -p 80:3000 --name metabase metabase / metabase`d

`az container create --resource-group MyResourceGroup --name metabase --image metabase/metabase --dns-name-label mb_app --ports 3000 --environment-variables MB_DB_TYPE=postgres MB_DB_DBNAME=metabase_azure_staging MB_DB_PORT=5432 MB_DB_USER=abc MB_DB_PASS=abc_password MB_DB_HOST=my_host.com`

I want my application to listen at port 80, hence I want to map this port 3000 t0 80. Equivalent command in docker would be 
`docker run -d -p 80:3000 --name metabase metabase/metabase`d

在azure中它的等效命令是什么? 

我试过`az容器创建 - resource-group MyResourceGroup --name metabase --image metabase / metabase --dns-name-label mb_app --ports 80:3000 --environment-variables MB_DB_TYPE = postgres MB_DB_DBNAME = metabase_azure_staging MB_DB_PORT = 5432 MB_DB_USER = abc
MB_DB_PASS = abc_password MB_DB_HOST = my_host.com`但它返回了错误。 



PS:我在这里发现了一个类似的问题  https://feedback.azure.com/forums/602224-azure-container-instances/suggestions/34082284-support-for-port-mapping  但
无法得到答案。 



请帮忙!

What is its equivalent command in azure? 
I tried doing `az container create --resource-group MyResourceGroup --name metabase --image metabase/metabase --dns-name-label mb_app --ports 80:3000 --environment-variables MB_DB_TYPE=postgres MB_DB_DBNAME=metabase_azure_staging MB_DB_PORT=5432 MB_DB_USER=abc MB_DB_PASS=abc_password MB_DB_HOST=my_host.com` but it returned error. 

PS: I found a similar question here https://feedback.azure.com/forums/602224-azure-container-instances/suggestions/34082284-support-for-port-mapping but couldn't get the answer. 

Please help!

谢谢提前!

推荐答案

目前尚不支持端口映射,目前的解决方法是在可能的情况下更改映像中的端口。当您使用公共映像时,可以考虑使用

AKS
,通过它可以完成端口映射。

Port mapping is not yet supported, current work around is to change the port in the image if that is possible. As you are using public image, you can consider usingAKS through which the port mapping can be done.

我会将这个功能带给产品团队注意。

I will bring this feature to product teams attention.

如果它解决了您的问题或者投票有帮助请求您将回复标记为答案帮助,以便其他社区成员可以发现它有用。

Requesting you to mark the reply as answer if it resolved your issue or vote as helpful if it helped so that other community members can find it helpful.

谢谢。


这篇关于如何在azure中进行端口映射 - (如何在创建docker镜像时在Azure上运行docker等效命令)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-18 19:08