pseudomonas
pseudomonas

Reputation: 432

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. Doing a curl on the obtained IPAddress with the specific port does not connect to the Docker.

Upvotes: 3

Views: 7466

Answers (3)

Gopi Kolla
Gopi Kolla

Reputation: 974

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)

Upvotes: 1

Jason Ye
Jason Ye

Reputation: 13954

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:

enter image description here

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

enter image description here

curl http://52.168.28.103:5000

Hope that helps.

Upvotes: 5

Chun-Yen Wang
Chun-Yen Wang

Reputation: 578

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

Upvotes: 2

Related Questions