1.
Download docker cli
1. Go to: https://www.docker.com/products/docker-desktop
2. Click Download for Windows.
3. Run the downloaded .exe installer.
4. Follow the install wizard steps.
5. Make sure WSL 2 is enabled when prompted.
6. Restart your PC after installation.
7. Open PowerShell or CMD.
8. Check version: docker --version
9. Test Docker: docker run hello-world
10. You’re ready to use Docker CLI on Windows!
2.creating a container in docker cli
A: Open Terminal / CMD / PowerShell.
B:Make sure Docker is running.
C: Pull an image (e.g., Ubuntu):
docker pull ubuntu
D: Check image is downloaded:
docker images
E: Run a container:
docker run -it ubuntu
F: You're now inside the container (interactive shell).
G: Run commands inside it, e.g.: apt update
H:Exit the container: type exit
3:running python file
1:Create a file named add.py with this content:
a=5
b=3
print("Sum:", a + b)
2:Create a file named Dockerfile in the same folder:
FROM python:3.9
COPY add.py /app/add.py
WORKDIR /app
CMD ["python", "add.py"]
3: Open terminal in that folder.
4: Build the Docker image:
~ $ docker build -t python-add .
5:Verify the image was built:
~ $ docker images
6:Run the container:
~ $ docker run python-add
7: You’ll see: Sum: 8 🎉
8: To modify the program, edit add.py and rebuild the image.
9: Check container history (optional):
~ $ docker ps -a
10:Remove container/image if needed:
~ $ docker rm <container_id> && docker rmi python-add