top of page

How to Create a simple Python “Hello World” project - Dockerize it -Push it to GitHub using VS Code.


Step 1 — Create project folder in VS Code

  1. Open VS Code

  2. Go to File → Open Folder

  3. Create/open a folder named:hello-docker-python

Step 2 — Create files

Inside VS Code, create these files:

📄 1. hello.py

print("Hello from Dockerized Python!")

📄 2. Dockerfile

FROM python:3.11-slim
WORKDIR /app
COPY hello.py .
CMD ["python", "hello.py"]

📄 3. .dockerignore

__pycache__
*.pyc
.git

📄 4. README.md

Simple Python Docker demo.

Run:
  docker build -t hello-python .
  docker run --rm hello-python

Step 3 — Test Docker locally (optional but recommended)

Open VS Code terminal:Ctrl + `

Run:

docker build -t hello-python .

Then run:

docker run --rm hello-python

Expected output:

Hello from Dockerized Python!

If you see this, Docker is correct.

Step 4 — Upload project to GitHub from VS Code

A) Create empty GitHub repo

  1. Go to GitHub → New Repository

  2. Name: hello-docker-python

  3. Do NOT add README

Copy your repository HTTPS URL, example:

B) Push your project from VS Code

In the VS Code terminal, run these commands:

git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin https://github.com/yourname/hello-docker-python.git
git push -u origin main

(Replace the URL with your own)

DONE!

You will now see all your files on GitHub:

$50

Product Title

Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button

$50

Product Title

Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button.

$50

Product Title

Product Details goes here with the simple product description and more information can be seen by clicking the see more button. Product Details goes here with the simple product description and more information can be seen by clicking the see more button.

Recommended Products For This Post
 
 
 

Recent Posts

See All
Jenkins Setup

Go to CMD and and type below command docker pull jenkins/jenkins:lts After that write the below command docker run -d --name jenkins -p 8080:8080 -p 50000:50000 -v jenkins_home:/var/jenkins_home jenki

 
 
 
Demonstration of How to Do Port Mapping in Docker

STEP 1: Run NGINX on Port 8080 docker run -d --name mynginx -p 8080:80 nginx NGINX is running inside container on port 80 ✔ You are accessing it from host on 8080 Test: http://localhost:8080 STEP 2: T

 
 
 

Comments


© 2023 by newittrendzzz.com 

  • Facebook
  • Twitter
  • Instagram
bottom of page