Home > Blockchain >  Azure VM/Docker – Access website deployed as Docker Container on Azure VM (Debian)
Azure VM/Docker – Access website deployed as Docker Container on Azure VM (Debian)

Time:10-07

I am trying to deploy simple website as Docker Conteiner on Azure Virtual Machine port 80.

Procedure:

1 – Create VM and open port 80:

az group create --name my-vm-rg --location germanywestcentral
az vm create --resource-group my-vm-rg --name linuxVM --image Debian --admin-username <admin_user> --admin-password <admin_password> --authentication-type password --public-ip-sku Standard --size Standard_B1ms --disable-integrity-monitoring
az vm open-port --resource-group my-vm-rg --name linuxVM --port 80

2 – Connect to VM using Putty and install Docker, nano, update machine etc.

3 – Create new folder and simple index.html with <h1>Hello World</h1>

4 – Create Dockerfile

FROM nginx:1.17.1-alpine
LABEL maintainer="Name Surname <email>" description="Some random description"
COPY . /usr/share/nginx/html

5 – Build Dockerfile:

docker build -t docker-test-img .
docker image ls -a
docker run --name my-app -d -p 8080:80 docker-test-img
docker container ls -a

QUESTION: Docker container is running, but I can not access website from my local computer browser using <machine_ip_address>:80 or <machine_ip_address>:8080. I am getting „This site can’t be reached” error.

Why do I need it? I am trying to learn something new and yes, it has to be Azure VM. OS can be different.

CodePudding user response:

Since you're opening port 80 in your VM, you should run your container using -p 80:80 instead.

  • Related