<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Adem Cayir on Medium]]></title>
        <description><![CDATA[Stories by Adem Cayir on Medium]]></description>
        <link>https://medium.com/@ademcayir?source=rss-285a00763f67------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*ojMdhO2lla7fGVaS.jpeg</url>
            <title>Stories by Adem Cayir on Medium</title>
            <link>https://medium.com/@ademcayir?source=rss-285a00763f67------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 04:12:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ademcayir/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Kubernetes and Docker in Azure]]></title>
            <link>https://medium.com/@ademcayir/kubernetes-and-docker-in-azure-d4d7a751c687?source=rss-285a00763f67------2</link>
            <guid isPermaLink="false">https://medium.com/p/d4d7a751c687</guid>
            <category><![CDATA[kubernates]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[azure-kubernetes-service]]></category>
            <category><![CDATA[azure-container-registry]]></category>
            <dc:creator><![CDATA[Adem Cayir]]></dc:creator>
            <pubDate>Mon, 26 Feb 2024 09:17:12 GMT</pubDate>
            <atom:updated>2024-02-26T09:17:12.280Z</atom:updated>
            <content:encoded><![CDATA[<p>This article will explain how to manage Kubernates (Azure Kubernetes Service — AKS) and Docker in Azure with a Mac M1 computer.</p><p>Docker image will be created locally and pushed to Azure Container Registry (ACR). So, you will understand how to create image, and how it flows from a computer (in our example, your computer) to a Kubernates service. I will also explain some possible problems and how to debug.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/941/1*Up-J3nqmlbBtT5F--QXBgg.png" /></figure><p>You should first start by writing an application and should work in your local computer. I choose one of Node.js framework, express (<a href="https://expressjs.com/">https://expressjs.com/</a>). Hello world example is enough.</p><p>Lets start with create and run a simple hello world express application. To create a simple hello world, I use express-generator. So,</p><pre>$ npm init<br>// enter project details. you can continue with default parameters<br>$ npm install -g express-generator<br>$ express<br>// then, you can continue with default parameters.<br>// and install dependencies<br>$ npm install<br>// to test application<br>$ npm start<br>// and open, http://localhost:3000</pre><p>At the end of this commands, you should have a project like</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KYvvmtauT5AenVqk0mj7Ew.png" /></figure><p>And when after you execute “npm start” command, you should see index page of express page. You can open view/index.jade to play with this page. So, lets go next step.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5SJTzmjBi5zUfT32TVy-aw.png" /></figure><p>Next step is we need to containerize this node.js application as docker container.</p><p>Create “Dockerfile” file in the root folder of the project, and place this lines</p><pre># Use an official Node.js runtime as the base image<br>FROM --platform=linux/amd64 node:14<br># Set the working directory in the container<br>WORKDIR /app<br># Copy package.json and package-lock.json to the container<br>COPY package*.json ./<br># Install application dependencies<br>RUN npm install<br># Copy the rest of the application code to the container<br>COPY . .<br># Expose the port the application listens on<br>EXPOSE 3000<br># Command to run the application<br>CMD npm start</pre><p><em>Note: I am Mac M1 user. In my first attempt, I didn’t have — platform=linux/amd64 in first line. Because of that, when I built the docker image, it was built for “Mac M1” PC, and when I deployed to Kubernates cloud, Because of Kubernates cloud is NOT Mac M1, application itself did not start. So, you have to add this parameter if your PC’s architecture is different that Kubernates Cloud architecture.</em></p><p>Now, we have a running node.js application and we have a Dockerfile. So that, lets create Docker Image with this.</p><pre>$ docker build -t hello-world-app .</pre><p>This command will create Docker Image from the node.js applicaiton.</p><p><em>Note: If you get such an error, this means you need to start Docker</em></p><pre>$ ERROR: Cannot connect to the Docker daemon at unix:///Users/myuser/.docker/run/docker.sock. Is the docker daemon running?</pre><p><em>Simplest way is open Docker Desktop. You can start Docker Desktop with a command or command + Space</em></p><pre>$ open -a Docker</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FwxsNn6r3eQSKN0_SWxEGg.png" /></figure><p>Now, after you run Docker build, you should see image is created</p><pre>$ myuser@mypc k8s demo % docker build -t hello-world-app .<br>[+] Building 46.1s (10/10) FINISHED                                                                                 docker:desktop-linux<br> =&gt; [internal] load build definition from Dockerfile                                                                                0.0s<br> =&gt; =&gt; transferring dockerfile: 487B                                                                                                0.0s<br> =&gt; [internal] load metadata for docker.io/library/node:14                                                                          7.2s<br> =&gt; [internal] load .dockerignore                                                                                                   0.0s<br> =&gt; =&gt; transferring context: 2B                                                                                                     0.0s<br> =&gt; [1/5] FROM docker.io/library/node:14@sha256:a158d3b9b4e3fa813fa6c8c590b8f0a860e015ad4e59bbce5744d2f6fd8461aa                    0.0s<br> =&gt; [internal] load build context                                                                                                   1.2s<br> =&gt; =&gt; transferring context: 6.10MB                                                                                                 1.2s<br> =&gt; CACHED [2/5] WORKDIR /app                                                                                                       0.0s<br> =&gt; [3/5] COPY package*.json ./                                                                                                     0.0s<br> =&gt; [4/5] RUN npm install                                                                                                          37.4s<br> =&gt; [5/5] COPY . .                                                                                                                  0.1s <br> =&gt; exporting to image                                                                                                              0.1s <br> =&gt; =&gt; exporting layers                                                                                                             0.1s <br> =&gt; =&gt; writing image sha256:25176560e3dfb37e6992549f8a583e8a1a1e1ffbd16a015d557e3b1ed0861c6c                                        0.0s <br> =&gt; =&gt; naming to docker.io/library/hello-world-app                                                                                  0.0s <br>                                                                                                                                         <br>What&#39;s Next?<br>  View a summary of image vulnerabilities and recommendations → docker scout quickview</pre><p>So, this output means, “hello-world-app” docker image is created successfully. So, now, we should check if this docker image is working fine.</p><pre>$ myuser@mypc k8s demo % docker run --rm -p 3000:3000 hello-world-app<br>WARNING: The requested image&#39;s platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested<br><br>&gt; k8s-demo@0.0.0 start /app<br>&gt; node ./bin/www</pre><p>This command create and run a container from the docker image. -p provides docker port of 3000 is exposed. WARNING line means, architecture of the PC and, parameter in the FROM of Dockerfile are different. next two lines means, application is started successfully and logs are coming from default express application. Open browser and check if you see your app’s open page in <a href="http://localhost:3000/">http://localhost:3000/</a> address.</p><p>So, now we have a running docker image. Next step is creating a kubernates cluster in Azure. I created a dedicated resource group for this activity. So that, once I am done, I can delete all resources quickly.</p><p>Then, you should create a deployment.yaml file to define how the docker image will be deployed.</p><pre>$ myuser@mypc k8s demo % az aks create --resource-group myaksgroup --name mycluster --node-count 1 --enable-addons monitoring --generate-ssh-keys<br><br>{<br>  &quot;aadProfile&quot;: null,<br>  &quot;addonProfiles&quot;: {<br>    &quot;omsagent&quot;: {<br>      &quot;config&quot;: {<br>        &quot;logAnalyticsWorkspaceResourceID&quot;: &quot;/subscriptions/0862d310-0000-0000-0000-22b598226aa4/resourceGroups/DefaultResourceGroup-NEU/providers/Microsoft.OperationalInsights/workspaces/DefaultWorkspace-0862d310-0000-0000-0000-22b598226aa4-NEU&quot;,<br>        &quot;useAADAuth&quot;: &quot;true&quot;<br>         ....</pre><p>Install kubectl to your PC, <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/">https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/</a> .</p><p>Then, create deployment.yaml file to define how the docker image will bed deployed. Most important line in here is, “image: hello-world-app: latest”. So, this line defines what docker image will be loaded to the kubernates clustering.</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: hello-world-deployment<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: hello-world<br>  strategy:<br>    type: RollingUpdate<br>    rollingUpdate:<br>      maxSurge: 0<br>      maxUnavailable: 1<br>  template:<br>    metadata:<br>      labels:<br>        app: hello-world<br>    spec:<br>      containers:<br>      - name: hello-world-container<br>        image: hello-world-app:latest<br>        ports:<br>        - containerPort: 3000<br>        imagePullPolicy: Always</pre><p>Now, deploy this yaml to azure. But before calling this, you should retrieve credentials.</p><pre># you may get &quot;A different object named mycluster already exists in your kubeconfig file.&quot;<br># this means, you already have a connection to another kubernates. <br># you should manage this. You can overwrite config if that&#39;s ok for you<br>$ myuser@mypc k8s demo % az aks get-credentials --resource-group myaksgroup --name mycluster<br>Merged &quot;mycluster&quot; as current context in /Users/mypc/.kube/config</pre><p>Then, you should run kubectl apply -f deployment.yaml</p><pre>$ myuser@mypc k8s demo % kubectl apply -f deployment.yaml<br>deployment.apps/hello-world-deployment created</pre><p>This means, you deployment configuration is deployed successfully. Next step is creating a load balancer service. Because kubernates clustering is not directly open to the internet. You need to have a load balancer in front of kubernates. So, lets create a load balancer service. Create service.yaml file in root folder.</p><pre>apiVersion: v1<br>kind: Service<br>metadata:<br>  name: hello-world-service<br>spec:<br>  selector:<br>    app: hello-world<br>  ports:<br>    - protocol: TCP<br>      port: 80<br>      targetPort: 3000<br>  type: LoadBalancer</pre><p>Then load this to the kubernates.</p><pre>$ myuser@mypc k8s demo % kubectl apply -f service.yaml<br>service/hello-world-service created</pre><p>This means load balancer is also deployed successfully. Then check what is the public IP address of the Load Balancer. So that, you can reach your applicaiton</p><pre>$ myuser@myp k8s demo % kubectl get svc hello-world-service<br>NAME                  TYPE           CLUSTER-IP    EXTERNAL-IP   PORT(S)        AGE<br>hello-world-service   LoadBalancer   10.0.15.198   4.210.16.1    80:30769/TCP   66s</pre><p>4.210.16.1 is public IP. So, you should be able to reach your application on <a href="http://4.210.16.1/">http://4.210.16.1</a> , but when you try, it keeps loading but at the end it will not reach your application.</p><p>Run this command, and it will show what is the error in kubernates.</p><pre>$ myuser@mypc k8s demo % kubectl describe pod<br>Name:             hello-world-deployment-fb68bd75c-wxndz<br>Namespace:        default<br>Priority:         0<br>Service Account:  default<br>Node:             aks-nodepool1-30655653-vmss000000/10.224.0.4<br>Start Time:       Sun, 25 Feb 2024 23:32:02 +0000<br>Labels:           app=hello-world<br>                  pod-template-hash=fb68bd75c<br>Annotations:      &lt;none&gt;<br>Status:           Pending<br>IP:               10.244.0.15<br>IPs:<br>  IP:           10.244.0.15<br>Controlled By:  ReplicaSet/hello-world-deployment-fb68bd75c<br>Containers:<br>  hello-world-container:<br>    Container ID:   <br>    Image:          hello-world-app:latest<br>    Image ID:       <br>    Port:           3000/TCP<br>    Host Port:      0/TCP<br>    State:          Waiting<br>      Reason:       ImagePullBackOff<br>    Ready:          False<br>    Restart Count:  0<br>    Environment:    &lt;none&gt;<br>    Mounts:<br>      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-c5znk (ro)<br>Conditions:<br>  Type              Status<br>  Initialized       True <br>  Ready             False <br>  ContainersReady   False <br>  PodScheduled      True <br>Volumes:<br>  kube-api-access-c5znk:<br>    Type:                    Projected (a volume that contains injected data from multiple sources)<br>    TokenExpirationSeconds:  3607<br>    ConfigMapName:           kube-root-ca.crt<br>    ConfigMapOptional:       &lt;nil&gt;<br>    DownwardAPI:             true<br>QoS Class:                   BestEffort<br>Node-Selectors:              &lt;none&gt;<br>Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s<br>                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s<br>Events:<br>  Type     Reason     Age                     From               Message<br>  ----     ------     ----                    ----               -------<br>  Normal   Scheduled  8m47s                   default-scheduler  Successfully assigned default/hello-world-deployment-fb68bd75c-wxndz to aks-nodepool1-30655653-vmss000000<br>  Normal   Pulling    7m14s (x4 over 8m46s)   kubelet            Pulling image &quot;hello-world-app:latest&quot;<br>  Warning  Failed     7m13s (x4 over 8m45s)   kubelet            Failed to pull image &quot;hello-world-app:latest&quot;: rpc error: code = Unknown desc = failed to pull and unpack image &quot;docker.io/library/hello-world-app:latest&quot;: failed to resolve reference &quot;docker.io/library/hello-world-app:latest&quot;: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed<br>  Warning  Failed     7m13s (x4 over 8m45s)   kubelet            Error: ErrImagePull<br>  Warning  Failed     7m2s (x6 over 8m45s)    kubelet            Error: ImagePullBackOff<br>  Normal   BackOff    3m40s (x20 over 8m45s)  kubelet            Back-off pulling image &quot;hello-world-app:latest&quot;</pre><p>This lines tell about the error:</p><p>Warning Failed 7m13s (x4 over 8m45s) kubelet Failed to pull image “hello-world-app:latest”: rpc error: code = Unknown desc = failed to pull and unpack image “docker.io/library/hello-world-app:latest”: failed to resolve reference “docker.io/library/hello-world-app:latest”: pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed</p><p>So, as you see, Azure tries to get “hello-world-app:latest” docker image from “docker.io”, but it can not. Because, the docker image is still in our PC. You can either upload to docker.io or you can use Azure Container Registry(ACR). I will use ACR in this example. ACR is simply an azure service to keep your docker images. Lets create a ACR.</p><pre>$ myuser@mypc k8s demo % az acr create --resource-group myaksgroup --name myaksdockerdemo --sku Basic<br><br>{<br>  &quot;adminUserEnabled&quot;: false,<br>  &quot;anonymousPullEnabled&quot;: false,<br>  &quot;creationDate&quot;: &quot;2024-02-26T00:19:03.000501+00:00&quot;,<br>  &quot;dataEndpointEnabled&quot;: false,<br>  &quot;dataEndpointHostNames&quot;: [],<br>  &quot;encryption&quot;: {<br>    &quot;keyVaultProperties&quot;: null,<br>    &quot;status&quot;: &quot;disabled&quot;<br>  },<br>  &quot;id&quot;: &quot;/subscriptions/0862d310-0000-0000-0000-22b598226aa4/resourceGroups/myaksgroup/providers/Microsoft.ContainerRegistry/registries/myaksdockerdemo&quot;,<br>  &quot;identity&quot;: null,<br>  &quot;location&quot;: &quot;northeurope&quot;,<br>  &quot;loginServer&quot;: &quot;myaksdockerdemo.azurecr.io&quot;,<br>  &quot;name&quot;: &quot;myaksdockerdemo&quot;,<br>  &quot;networkRuleBypassOptions&quot;: &quot;AzureServices&quot;,<br>  &quot;networkRuleSet&quot;: null,<br>  &quot;policies&quot;: {<br>    &quot;azureAdAuthenticationAsArmPolicy&quot;: {<br>      &quot;status&quot;: &quot;enabled&quot;<br>    },<br>    &quot;exportPolicy&quot;: {<br>      &quot;status&quot;: &quot;enabled&quot;<br>    },<br>    &quot;quarantinePolicy&quot;: {<br>      &quot;status&quot;: &quot;disabled&quot;<br>    },<br>    &quot;retentionPolicy&quot;: {<br>      &quot;days&quot;: 7,<br>      &quot;lastUpdatedTime&quot;: &quot;2024-02-26T00:19:09.654121+00:00&quot;,<br>      &quot;status&quot;: &quot;disabled&quot;<br>    },<br>    &quot;softDeletePolicy&quot;: {<br>      &quot;lastUpdatedTime&quot;: &quot;2024-02-26T00:19:09.654164+00:00&quot;,<br>      &quot;retentionDays&quot;: 7,<br>      &quot;status&quot;: &quot;disabled&quot;<br>    },<br>    &quot;trustPolicy&quot;: {<br>      &quot;status&quot;: &quot;disabled&quot;,<br>      &quot;type&quot;: &quot;Notary&quot;<br>    }<br>  },<br>  &quot;privateEndpointConnections&quot;: [],<br>  &quot;provisioningState&quot;: &quot;Succeeded&quot;,<br>  &quot;publicNetworkAccess&quot;: &quot;Enabled&quot;,<br>  &quot;resourceGroup&quot;: &quot;myaksgroup&quot;,<br>  &quot;sku&quot;: {<br>    &quot;name&quot;: &quot;Basic&quot;,<br>    &quot;tier&quot;: &quot;Basic&quot;<br>  },<br>  &quot;status&quot;: null,<br>  &quot;tags&quot;: {},<br>  &quot;type&quot;: &quot;Microsoft.ContainerRegistry/registries&quot;,<br>  &quot;zoneRedundancy&quot;: &quot;Disabled&quot;<br>}</pre><p>So, now we have a ACR named myaksdockerdemo. myaksdockerdemo and mycluser (AKS) are two different resources. There is not direct authentication between these two resources in default. To attach ACR to AKS, run this command</p><pre>$ myuser@mypc k8s demo % az aks update -n mycluster -g myaksgroup --attach-acr myaksdockerdemo<br>Could not find service principal or user assigned MSI for roleassignment<br>AAD role propagation done[############################################]  100.0000%{<br>&quot;aadProfile&quot;: null,<br>  &quot;addonProfiles&quot;: {<br>    &quot;omsagent&quot;: {<br>      &quot;config&quot;: {....</pre><p>Then, lets check if connection between AKS to ACR is fine.</p><pre>$ myuser@mypc k8s demo % az aks check-acr --name mycluster --resource-group myaksgroup --acr myaksdockerdemo<br>The login server endpoint suffix &#39;.azurecr.io&#39; is automatically appended.<br>Merged &quot;mycluster&quot; as current context in /var/folders/_m/hq9lkw3n6dx0wl_xkfm0k_zm0000gn/T/tmpvw9qp4s4<br>[2024-02-26T00:38:11Z] Checking host name resolution (myaksdockerdemo.azurecr.io): SUCCEEDED<br>[2024-02-26T00:38:11Z] Canonical name for ACR (myaksdockerdemo.azurecr.io): r0206neu-az.northeurope.cloudapp.azure.com.<br>[2024-02-26T00:38:11Z] ACR location: northeurope<br>[2024-02-26T00:38:11Z] Checking managed identity...<br>[2024-02-26T00:38:11Z] Kubelet managed identity client ID: 77e24415-3a67-45d2-af5a-09bbc5957f77<br>[2024-02-26T00:38:11Z] Validating managed identity existance: SUCCEEDED<br>[2024-02-26T00:38:11Z] Validating image pull permission: SUCCEEDED<br>[2024-02-26T00:38:11Z] <br>Your cluster can pull images from myaksdockerdemo.azurecr.io!</pre><p>as you see in the last line, now AKS can pull the docker images from ACR. Next step is, upload local image to ACR. Before uploading, lets login to ACR</p><pre>$ myuser@mypc k8s demo % az acr login -n myaksdockerdemo.azurecr.io<br>The login server endpoint suffix &#39;.azurecr.io&#39; is automatically omitted.<br>Login Succeeded</pre><p>Our local docker image name is, “hello-world-app”. To define this image as an image inside ACR, we should tag this docker image.</p><pre>$ docker tag hello-world-app myaksdockerdemo.azurecr.io/hello-world-app:latest</pre><p>Now, we have a docker image as “myaksdockerdemo.azurecr.io/hello-world-app:latest” locally. We need to push this to the ACR. Depends on your internet connection speed and docker image size, it may take some time</p><pre>$ myuser@mypc k8s demo % docker push myaksdockerdemo.azurecr.io/hello-world-app:latest<br>The push refers to repository [myaksdockerdemo.azurecr.io/hello-world-app]<br>3e29628b9c09: Pushed <br>cc1888997421: Pushed <br>4215831d3c42: Pushed <br>742091dcf23b: Pushed <br>0d5f5a015e5d: Pushed <br>3c777d951de2: Pushed <br>f8a91dd5fc84: Pushed <br>cb81227abde5: Pushed <br>e01a454893a9: Pushed <br>c45660adde37: Pushed <br>fe0fb3ab4a0f: Pushed <br>f1186e5061f2: Pushed <br>b2dba7477754: Pushed <br>latest: digest: sha256:b2c159c59412fe38bb8d9e360b45b9dd81dd8bbb9dc46fa166902e410e96fdc7 size: 3052</pre><p>This means, your local image is uploaded to ACR. But still we have a problem. In our deployment.yaml file, we told kubernates, pull the “hello-world-app” image. So, it still tries pull it from default docker registry. So, lets change this in deployment.yaml and change “image” property to tell that the docker image is residing on “myaksdockerdemo.azurecr.io”. Note that, we tag local docker as “myaksdockerdemo.azurecr.io/hello-world-app:latest” and use it in deployment.yaml</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: hello-world-deployment<br>spec:<br>  replicas: 1<br>  selector:<br>    matchLabels:<br>      app: hello-world<br>  strategy:<br>    type: RollingUpdate<br>    rollingUpdate:<br>      maxSurge: 0<br>      maxUnavailable: 1<br>  template:<br>    metadata:<br>      labels:<br>        app: hello-world<br>    spec:<br>      containers:<br>      - name: hello-world-container<br>        image: myaksdockerdemo.azurecr.io/hello-world-app:latest<br>        ports:<br>        - containerPort: 3000<br>        imagePullPolicy: Always</pre><p>then, update deployment.yaml file in AKS</p><pre>$ myuser@mypc k8s demo % kubectl apply -f deployment.yaml<br>deployment.apps/hello-world-deployment configured</pre><p>then call, “kubectl describe pods” to check if everything is ok</p><pre>$ myuser@mypc k8s demo % kubectl describe pods           <br>Name:             hello-world-deployment-6988fff98d-stm9j<br>Namespace:        default<br>Priority:         0<br>Service Account:  default<br>Node:             aks-nodepool1-30655653-vmss000000/10.224.0.4<br>Start Time:       Mon, 26 Feb 2024 00:58:32 +0000<br>Labels:           app=hello-world<br>                  pod-template-hash=6988fff98d<br>Annotations:      &lt;none&gt;<br>Status:           Pending<br>IP:               <br>IPs:              &lt;none&gt;<br>Controlled By:    ReplicaSet/hello-world-deployment-6988fff98d<br>Containers:<br>  hello-world-container:<br>    Container ID:   <br>    Image:          myaksdockerdemo.azurecr.io/hello-world-app:latest<br>    Image ID:       <br>    Port:           3000/TCP<br>    Host Port:      0/TCP<br>    State:          Waiting<br>      Reason:       ContainerCreating<br>    Ready:          False<br>    Restart Count:  0<br>    Environment:    &lt;none&gt;<br>    Mounts:<br>      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-75ht6 (ro)<br>Conditions:<br>  Type              Status<br>  Initialized       True <br>  Ready             False <br>  ContainersReady   False <br>  PodScheduled      True <br>Volumes:<br>  kube-api-access-75ht6:<br>    Type:                    Projected (a volume that contains injected data from multiple sources)<br>    TokenExpirationSeconds:  3607<br>    ConfigMapName:           kube-root-ca.crt<br>    ConfigMapOptional:       &lt;nil&gt;<br>    DownwardAPI:             true<br>QoS Class:                   BestEffort<br>Node-Selectors:              &lt;none&gt;<br>Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 300s<br>                             node.kubernetes.io/unreachable:NoExecute op=Exists for 300s<br>Events:<br>  Type    Reason     Age   From               Message<br>  ----    ------     ----  ----               -------<br>  Normal  Scheduled  3s    default-scheduler  Successfully assigned default/hello-world-deployment-6988fff98d-stm9j to aks-nodepool1-30655653-vmss000000<br>  Normal  Pulling    3s    kubelet            Pulling image &quot;myaksdockerdemo.azurecr.io/hello-world-app:latest&quot;</pre><p>so, as you see this means uploaded docker image is successfully pulled by AKS. so, when you go back to browser and check, you will see it is working now.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ZU1YPwFppL-M3KWwP28OA.png" /></figure><p>Last note, if you want to update docker image, you should build, tag and push. When you are pushing, if you get “unauthorized” response, you should login to acr once.</p><p>Docker build:</p><pre>$ myuser@mypc k8s demo % docker build -t hello-world-app .<br>[+] Building 1.7s (10/10) FINISHED                                                                                                                                                                                               docker:desktop-linux<br> =&gt; [internal] load build definition from Dockerfile                                                                                                                                                                                             0.0s<br> =&gt; =&gt; transferring dockerfile: 494B                                                                                                                                                                                                             0.0s<br> =&gt; [internal] load metadata for docker.io/library/node:14                                                                                                                                                                                       1.3s<br> =&gt; [internal] load .dockerignore                                                                                                                                                                                                                0.0s<br> =&gt; =&gt; transferring context: 2B                                                                                                                                                                                                                  0.0s<br> =&gt; [1/5] FROM docker.io/library/node:14@sha256:a158d3b9b4e3fa813fa6c8c590b8f0a860e015ad4e59bbce5744d2f6fd8461aa                                                                                                                                 0.0s<br> =&gt; [internal] load build context                                                                                                                                                                                                                0.1s<br> =&gt; =&gt; transferring context: 72.93kB                                                                                                                                                                                                             0.1s<br> =&gt; CACHED [2/5] WORKDIR /app                                                                                                                                                                                                                    0.0s<br> =&gt; CACHED [3/5] COPY package*.json ./                                                                                                                                                                                                           0.0s<br> =&gt; CACHED [4/5] RUN npm install                                                                                                                                                                                                                 0.0s<br> =&gt; [5/5] COPY . .                                                                                                                                                                                                                               0.2s<br> =&gt; exporting to image                                                                                                                                                                                                                           0.1s<br> =&gt; =&gt; exporting layers                                                                                                                                                                                                                          0.0s<br> =&gt; =&gt; writing image sha256:c7e2e7eccad7dec00b7cce1803678225a029a1e8309b67c2fb779c805b972844                                                                                                                                                     0.0s<br> =&gt; =&gt; naming to docker.io/library/hello-world-app                                                                                                                                                                                               0.0s<br><br>What&#39;s Next?<br>  View a summary of image vulnerabilities and recommendations → docker scout quickview</pre><p>Docker tagging:</p><pre>$ myuser@mypc k8s demo % docker tag hello-world-app myaksdockerdemo.azurecr.io/hello-world-app:latest</pre><p>Docker pushing:</p><pre>$ myuser@mypc k8s demo % docker push myaksdockerdemo.azurecr.io/hello-world-app:latest<br>The push refers to repository [myaksdockerdemo.azurecr.io/hello-world-app]<br>847bd4183dd2: Preparing <br>cc1888997421: Preparing <br>4215831d3c42: Preparing <br>742091dcf23b: Preparing <br>0d5f5a015e5d: Preparing <br>3c777d951de2: Waiting <br>f8a91dd5fc84: Waiting <br>cb81227abde5: Waiting <br>e01a454893a9: Waiting <br>c45660adde37: Waiting <br>fe0fb3ab4a0f: Waiting <br>f1186e5061f2: Waiting <br>b2dba7477754: Waiting <br>unauthorized: </pre><p>as you see, last line indicates, our access attempt to “myaksdockerdemo.azurecr.io” is unauthorized. So, lets login once:</p><pre>$ myuser@mypc k8s demo % az acr login --name myaksdockerdemo<br>Login Succeeded</pre><p>Then, docker push again:</p><pre>$ myuser@mypc k8s demo % docker push myaksdockerdemo.azurecr.io/hello-world-app:latest<br>The push refers to repository [myaksdockerdemo.azurecr.io/hello-world-app]<br>847bd4183dd2: Pushed <br>cc1888997421: Layer already exists <br>4215831d3c42: Layer already exists <br>742091dcf23b: Layer already exists <br>0d5f5a015e5d: Layer already exists <br>3c777d951de2: Layer already exists <br>f8a91dd5fc84: Layer already exists <br>cb81227abde5: Layer already exists <br>e01a454893a9: Layer already exists <br>c45660adde37: Layer already exists <br>fe0fb3ab4a0f: Layer already exists <br>f1186e5061f2: Layer already exists <br>b2dba7477754: Layer already exists <br>latest: digest: sha256:d3420184f7d49373ce7aee491d63032ffd986f560509eb298147516674ddb94c size: 3052</pre><p>And force AKS to pull docker image from ACR.</p><pre>$ myuser@mypc k8s demo % kubectl rollout restart deployment<br>deployment.apps/hello-world-deployment restarted</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d4d7a751c687" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>