ML Assignment Day2

How to Add Files into a Docker Image and Run it Step 1: Create or Update a Dockerfile Create a Dockerfile in your project folder (or update it if it already exists). Example Dockerfile: FROM python:3.11 WORKDIR /app COPY . . RUN pip install -r requirement.txt CMD ["python","ML.py"] Step 2: Build the Docker Image Use the docker build command to create an image from your Dockerfile. docker build -t assignment-image . -t assignment-image gives your image a name. . means Docker will look for the Dockerfile in the current directory. Step 3: Run the Docker Container Now, run the container based on the image you built. docker run -it assignment-image -it lets you interact with the container’s terminal. Step 4: (Optional) Open Bash Shell Inside the Container If you want to enter inside the container to see the files manually: docker run -it assignment-image /bin/bash Then inside the container, you can list files:

Apr 28, 2025 - 16:27
 0
ML Assignment Day2

How to Add Files into a Docker Image and Run it

Step 1: Create or Update a Dockerfile

Create a Dockerfile in your project folder (or update it if it already exists).

Example Dockerfile:

FROM python:3.11

WORKDIR /app

COPY . .

RUN pip install -r requirement.txt

CMD ["python","ML.py"]

Step 2: Build the Docker Image

Use the docker build command to create an image from your Dockerfile.

docker build -t assignment-image .

-t assignment-image gives your image a name.

. means Docker will look for the Dockerfile in the current directory.

Step 3: Run the Docker Container

Now, run the container based on the image you built.

docker run -it assignment-image

-it lets you interact with the container’s terminal.

Step 4: (Optional) Open Bash Shell Inside the Container

If you want to enter inside the container to see the files manually:

docker run -it assignment-image /bin/bash

Then inside the container, you can list files: