Prerequisites:
//Install Docker Desktop
Docker Desktop https://www.docker.com/products/docke...
// Sign up for Docker Hub
https://hub.docker.com/
// on linux
sudo yum install docker
sudo docker login
// username and password of dockerhub account needed for practice.
// Create project folder
cd D:/project
mkdir pythondocker
cd .\pythondocker2\
// create a program code
New-Item test.py
OR
touch test.py
// Copy following code to python file
```
print("Hello, World")
```
// Edit
code test.py
OR
notepad test.py
OR
nano test.py
// Run Locally
python test.py
// Create a Dockerfile
New-Item Dockerfile
OR
touch Dockerfile
// Edit Dockerfile
code Dockerfile
// paste following code to Dockerfile
```
FROM python:latest
WORKDIR /usr/app/src
COPY test.py ./
CMD [ "python", "./test.py"]
```
// list docker images
docker images
// build docker image from Dockerfile
docker build -t atuljkamble/pythonhelloworld .
// list images
docker images
// push docker image to Dockerhub
docker push atuljkamble/pythonhelloworld
// Pull Docker image and run locally
docker pull atuljkamble/pythonhelloworld
docker run atuljkamble/pythonhelloworld
Sur cette page du site, vous pouvez voir la vidéo en ligne Dockerize a Python Code durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Atul Kamble | LearnWithAtul 20 avril 2024, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 76 fois et il a aimé 1 téléspectateurs. Bon visionnage!