{"id":4600,"date":"2020-05-10T04:38:06","date_gmt":"2020-05-10T04:38:06","guid":{"rendered":"https:\/\/pariswells.com\/blog\/?p=4600"},"modified":"2020-05-10T04:39:29","modified_gmt":"2020-05-10T04:39:29","slug":"how-to-pull-image-from-docker-hub-and-upload-to-azure","status":"publish","type":"post","link":"https:\/\/pariswells.com\/blog\/research\/how-to-pull-image-from-docker-hub-and-upload-to-azure","title":{"rendered":"How to pull image from Docker Hub and Upload to azure"},"content":{"rendered":"<h2><strong>Run Locally<\/strong><\/h2><h3>Test and Download App<\/h3><p>#Downloads the Docker File from Dock Hub<\/p><pre>dock pull %dockerusername%\/%dockername%:latest\u00a0<\/pre><p>#Runs the Docker File on port 80 if the container is active on port 3000 ( Test go to http:\/\/localhost )\u00a0<\/p><pre>docker run -p 80:3000 %dockerusername%\/%dockername%:latest<\/pre><p>#List current dockers running<\/p><pre>docker ps -a<\/pre><p>#Stop the container by id ( found from above )<\/p><pre>docker stop ad5b49ba5476<\/pre><p>#Clear Stopped Containers<\/p><pre>docker container prune<\/pre><h3>Upload App to Azure<\/h3><p>**Create an Azure Container or reuse an existing one**\u00a0<\/p><p>**Run the below in Azure Shell**<\/p><p>#Show credentials for login and save username and password<\/p><pre>az acr credential show --name %azurecontainer%<\/pre><p>**Run on Docker PC**<\/p><p>#Login to Azure Docker<\/p><pre>docker login %azurecontainer%.azurecr.io --username name %azurecontainer%<\/pre><p>#Tag docker for upload<\/p><pre>docker tag %dockerusername%\/%dockername% name %azurecontainer%.azurecr.io\/%dockername%:latest<\/pre><p>#Push Docker to Azure<\/p><pre>docker push name %azurecontainer%.azurecr.io\/%dockerusername%\/%dockername%:latest<\/pre><h2><strong>Run in Azure<\/strong><\/h2><p>#Create Azure Service plan<\/p><pre>az appservice plan create --name %serviceplanname% --resource-group %azureresourcegroup% --sku S1 --is-linux<\/pre><p>#Add Docker App to Azure Service Plan<\/p><pre>az webapp create --resource-group %azureresourcegroup% --plan %serviceplanname% --name %appname% --deployment-container-image-name %azurecontainer%.azurecr.io\/%dockername%:latest<\/pre><p>#Set the details to access the Docker<\/p><pre>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%<\/pre><p>#Make the app live on its specific port e.g. 3000<\/p><pre>az webapp config appsettings set --resource-group %azureresourcegroup% --name %appname% --settings WEBSITES_PORT=3000<\/pre><p>Test the app<\/p><p>http:\/\/%appname%.azurewebsites.net\/<\/p><p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>Run LocallyTest and Download App#Downloads the Docker File from Dock Hubdock pull %dockerusername%\/%dockername%:latest\u00a0#Runs the Docker File on port 80 if the container is active on port 3000 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[3249,1464,3229,3243,3245,3244,3248,3247,3246],"class_list":["post-4600","post","type-post","status-publish","format-standard","hentry","category-research","tag-az-webapp","tag-azure","tag-docker","tag-docker-hub","tag-pull","tag-push","tag-s1","tag-service-plan","tag-upload"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/4600","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/comments?post=4600"}],"version-history":[{"count":6,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/4600\/revisions"}],"predecessor-version":[{"id":4636,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/posts\/4600\/revisions\/4636"}],"wp:attachment":[{"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/media?parent=4600"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/categories?post=4600"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pariswells.com\/blog\/wp-json\/wp\/v2\/tags?post=4600"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}