Dockerize a Python Code

Publicado em: 20 Abril 2024
no canal de: Atul Kamble | LearnWithAtul
76
1

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


Nesta página do site você pode assistir ao vídeo on-line Dockerize a Python Code duração hora minuto segundo em boa qualidade , que foi baixado pelo usuário Atul Kamble | LearnWithAtul 20 Abril 2024, compartilhe o link com seus amigos e conhecidos, no youtube este vídeo já foi visto 76 vezes e gostou 1 espectadores. Boa visualização!