How to pull image from Docker Hub and Upload to azure

Run Locally

Test and Download App

#Downloads the Docker File from Dock Hub

dock pull %dockerusername%/%dockername%:latest 

#Runs the Docker File on port 80 if the container is active on port 3000 ( Test go to http://localhost ) 

docker run -p 80:3000 %dockerusername%/%dockername%:latest

#List current dockers running

docker ps -a

#Stop the container by id ( found from above )

docker stop ad5b49ba5476

#Clear Stopped Containers

docker container prune

Upload App to Azure

**Create an Azure Container or reuse an existing one** 

**Run the below in Azure Shell**

#Show credentials for login and save username and password

az acr credential show --name %azurecontainer%

**Run on Docker PC**

#Login to Azure Docker

docker login %azurecontainer%.azurecr.io --username name %azurecontainer%

#Tag docker for upload

docker tag %dockerusername%/%dockername% name %azurecontainer%.azurecr.io/%dockername%:latest

#Push Docker to Azure

docker push name %azurecontainer%.azurecr.io/%dockerusername%/%dockername%:latest

Run in Azure

#Create Azure Service plan

az appservice plan create --name %serviceplanname% --resource-group %azureresourcegroup% --sku S1 --is-linux

#Add Docker App to Azure Service Plan

az webapp create --resource-group %azureresourcegroup% --plan %serviceplanname% --name %appname% --deployment-container-image-name %azurecontainer%.azurecr.io/%dockername%:latest

#Set the details to access the Docker

az webapp config container set --name %appname% --resource-group %azureresourcegroup% --docker-custom-image-name %azurecontainer%.azurecr.io/%dockername%:latest --docker-registry-server-url https://%azurecontainer%.azurecr.io --docker-registry-server-user %azurecontainer% --docker-registry-server-password %passwordfromshowcredential%

#Make the app live on its specific port e.g. 3000

az webapp config appsettings set --resource-group %azureresourcegroup% --name %appname% --settings WEBSITES_PORT=3000

Test the app

http://%appname%.azurewebsites.net/

 

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Tags: az webapp, Azure, docker, docker hub, pull, push, s1, service plan, upload

Trackback from your site.