简体   繁体   中英

How to connect to docker on Azure VM?

I have installed a DIGITS docker on my Azure VM. I am trying to connect to this Docker using its IP Address from my local machine (outside the VM). 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 . Doing a curl on the obtained IPAddress with the specific port does not connect to the Docker.

As Chun-Yen Wang said, you should add the port exposed to Azure NSG.
For example, I expose docker on port 5000, add inbound rules via Azure portal like this:

在此处输入图片说明

After that you can use Azure VM's public IP address to access it, you can find your public IP address here:

在此处输入图片说明

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:

  1. Public IP: there should be one when the VM is created.
  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".

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. 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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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