0% found this document useful (0 votes)
5 views2 pages

CC Dockerlab

This document provides a step-by-step guide on downloading and installing Docker CLI on Windows, creating a Docker container, and running a Python file within that container. It includes instructions for pulling an image, building a Docker image from a Python script, and running the container to see the output. Additionally, it covers how to modify the program and manage containers and images.

Uploaded by

123sanjaypurohit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

CC Dockerlab

This document provides a step-by-step guide on downloading and installing Docker CLI on Windows, creating a Docker container, and running a Python file within that container. It includes instructions for pulling an image, building a Docker image from a Python script, and running the container to see the output. Additionally, it covers how to modify the program and manage containers and images.

Uploaded by

123sanjaypurohit
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

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

You might also like