How To Integrate with Visual Studio Code, Azure Cloud Instance and Docker Desktop

Back in January , Docker and Microsoft Joined In Hand to Hand for New Strategic way to help developers and development teams to build and ship application better way . key part of this strategy to helping involve the ecosystem .

Indeed Visual Studio Code is One Of Best Tool For all Developer With lot of Open Source Extension . widely I use this Tool in day to day life

back in March 2002 GA , Microsoft released Docker Extension Support For Visual Studio Code .

Step 1: Installing Visual Studio Code

If You Don’t have Visual Studio Code You Can Install Via Link:-

After Installing Docker lets open the VScode .

Step 2 : Install Docker Extension For Visual Studio Code .

Step 3: Docker Desktop  & VS Code

What can I do with the Docker  Extension?

1.Bootstrap New Docker Projects

2.Interact with Containers, Images, Volumes,  Networks, and Docker Hosts

3.Write Dockerfiles with code completion

4.Build & Debug Compose and Dockerfiles

5.Connect to different Docker Servers

// Bootstrap New Docker Project 
// 1. create folder by name python-flask-docker 
inside folder create 3 files , Dockerfile , , requirement.txt with following content .

Create Dockerfile With Following Content :

FROM python:2.7
COPY . /app
RUN pip install -r requirements.txt
ENTRYPOINT ["python"]
CMD [""]

Create With Following Content:

from flask import Flask
import os
app = Flask(__name__)
def hello():
return "Flask inside Docker!!"
if __name__ == "__main__":
port = int(os.environ.get("PORT", 5000)),host='',port=port)

Create requirement.txt With Following Content:


Step 4: Build DockerFile and Run Dockerized

sangam$ docker build -t python-flask .
Sending build context to Docker daemon 4.096kB
Step 1/6 : FROM python:2.7
---> 68e7be49c28c
Step 2/6 : COPY . /app
---> Using cache
---> 24d32a079fc3
Step 3/6 : WORKDIR /app
---> Using cache
---> 91b7e9c6d982
Step 4/6 : RUN pip install -r requirements.txt
---> Using cache
---> 2c06e31a3135
Step 5/6 : ENTRYPOINT ["python"]
---> Using cache
---> 1eaf4973946d
Step 6/6 : CMD [""]
---> Using cache
---> d03e75d1abeb
Successfully built d03e75d1abeb
Successfully tagged python-flask:latest
sangam:Python-vscode-docker sangam$ docker run -d -p 5000:5000 python-flask:latest

Step 5: Check Containers Via Docker Extension in Visual Code

we are already installed docker extension so you will see powerful Docker UI right in vscode . python-flask:latest container is running and now using vscode with one click you can perform different commands like Docker Exec , Docker Exect jump in bash , Multiple containers Start / Stop /restart Containers , etc much more .

Step 6 : Creating Azure Container Registry.

visit to azure portal and search for container registry .

Step 7: enable admin more

Step 8 : login to azure container registry

docker login
Username: python101

Step 9: single command to build dockerfile and push directly to azure container registry

az acr build --image sangam14/python101 --registry python101 --file Dockerfile .

azure provide one of the easy way to build you dockerfile right from the CLI . az acr build basically take your dockerfile automatically from the host and do all docker build task and push it to ACR .

sangam:Documents sangam$ az acr repository list --name python101 --output table

using az acr repository command you can directly check registories .

Docker recently containerized azure cli so you can do this all things using azure cli docker Hub image

Step 10 : Check your Azure Container Registry via portal

congrats !! now our python101 application successfully pushed into ACR ! cheers !

You may also like...