如何在 Azure 容器实例中编辑 /etc/hosts?
How to edit /etc/hosts in Azure Container Instances?
我尝试通过 echo IP Hostname >> /etc/hosts 命令编辑 /etc/hosts,但似乎 ACI 重写了文件。
我已经尝试将其放入 dockerfile 并通过 --command-line 但 none 有效。
使用 Docker,它将在您执行 Docker CLI docker run
时为您管理 /etc/hosts
,请参阅
管理 /etc/hosts:
Your container will have lines in /etc/hosts which define the hostname
of the container itself as well as localhost and a few other common
things.
并且对于 Azure 容器实例,在创建容器实例时指定命令行以覆盖烘焙到容器映像中的命令行。这类似于 docker run
的 --entrypoint
命令行参数。容器实例将在执行命令后终止。有关详细信息,请参阅 Command line override。
我建议您可以通过 CLI 命令 az container exec containerName --exec-command "/bin/sh"
与容器实例进行交互 shell 如果图像具有 /bin/sh
并且容器实例具有 public IP.
如果你对容器的操作比较复杂,也许Azure Kubernetes Service更适合你。
我尝试通过 echo IP Hostname >> /etc/hosts 命令编辑 /etc/hosts,但似乎 ACI 重写了文件。 我已经尝试将其放入 dockerfile 并通过 --command-line 但 none 有效。
使用 Docker,它将在您执行 Docker CLI docker run
时为您管理 /etc/hosts
,请参阅
管理 /etc/hosts:
Your container will have lines in /etc/hosts which define the hostname of the container itself as well as localhost and a few other common things.
并且对于 Azure 容器实例,在创建容器实例时指定命令行以覆盖烘焙到容器映像中的命令行。这类似于 docker run
的 --entrypoint
命令行参数。容器实例将在执行命令后终止。有关详细信息,请参阅 Command line override。
我建议您可以通过 CLI 命令 az container exec containerName --exec-command "/bin/sh"
与容器实例进行交互 shell 如果图像具有 /bin/sh
并且容器实例具有 public IP.
如果你对容器的操作比较复杂,也许Azure Kubernetes Service更适合你。