简体   繁体   English

如何在Azure VM上连接到Docker?

[英]How to connect to docker on Azure VM?

I have installed a DIGITS docker on my Azure VM. 我在Azure VM上安装了DIGITS泊坞窗。 I am trying to connect to this Docker using its IP Address from my local machine (outside the VM). 我正在尝试使用本地计算机(VM外部)的IP地址连接到此Docker。 I have not had any success in doing so. 我这样做没有任何成功。 Is this even possible? 这有可能吗? If so, how? 如果是这样,怎么办?

I have the IP Address of the Docker from running docker inspect <container-ID> | grep IPAddress 我有从运行docker inspect <container-ID> | grep IPAddress的Docker的IP地址。 docker inspect <container-ID> | grep IPAddress . docker inspect <container-ID> | grep IPAddress Doing a curl on the obtained IPAddress with the specific port does not connect to the Docker. 在使用特定端口对获得的IPAddress进行卷曲时,不会连接到Docker。

As Chun-Yen Wang said, you should add the port exposed to Azure NSG. 正如王春燕所说,您应该添加暴露给Azure NSG的端口
For example, I expose docker on port 5000, add inbound rules via Azure portal like this: 例如,我将docker暴露在端口5000上,通过Azure门户添加入站规则,如下所示:

在此处输入图片说明

After that you can use Azure VM's public IP address to access it, you can find your public IP address here: 之后,您可以使用Azure VM的公共IP地址访问它,可以在这里找到您的公共IP地址:

在此处输入图片说明

curl http://52.168.28.103:5000

Hope that helps. 希望能有所帮助。

The docker containers on Azure VM can be accessed via the public IP address of the host VM, and the port exposed: 可以通过主机VM的公共IP地址以及暴露的端口访问Azure VM上的docker容器:

  1. Public IP: there should be one when the VM is created. 公用IP:创建VM时应该有一个。
  2. Port: whatever ports the docker container exposes, they need to be opened for web traffic, just like Create a Linux virtual machine with the Azure portal , section "Open port 80 for web traffic". 端口:无论docker容器公开了哪些端口,都需要打开它们以进行Web流量,就像使用Azure门户创建Linux虚拟机一样,“为Web流量打开80端口”部分。

Assuming your host/remote machine is running Linux - If you want to access the container (running on a remote server) directly from local machine you should first install SSH Server in the container and map the 22 port of container to a port on host. 假设主机/远程计算机运行的是Linux-如果要直接从本地计算机访问容器(在远程服务器上运行),则应首先在容器中安装SSH Server,然后将容器的22端口映射到主机上的端口。 And then open that host port and protocol TCP (to let SSH) for inbound traffic on NSG in Azure portal (as told by Chun/Jason) 然后打开该主机端口和协议TCP(以允许SSH)以在Azure门户中的NSG上进行入站流量(如Chun / Jason所述)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM