Hello, I have few questions on this task.
I did create my dockerfile but line 2 on WORKDIR keeps on failing, I can see a tag on my image. I dont know what I am doing wrong
My dockerfile
Docker images
Container keeps exiting
Hello, I have few questions on this task.
I did create my dockerfile but line 2 on WORKDIR keeps on failing, I can see a tag on my image. I dont know what I am doing wrong
My dockerfile
Docker images
Container keeps exiting
Hello,
The first thing I see is that it appears you are building your dockerfile in the wrong directory
The question says
Create a
Dockerfile
under/python_app
directory
From your screenshot, it looks like you did it in /python_app/src/
which is incorrect and why you get COPY failed
.
Next (and you haven’t seen this yet because docker build
didn’t get this far), you have only copied the requirements file and not server.py
to the container so there’s nothing to run.
See the final sentence of my previous reply - that’s your issue!
sorry but I am a bit confused here.
This is the task
Create a Dockerfile
under /python_app
directory:
python
image as the base image.requirements.txt
file.6400
.server.py
script using CMD
.are you saying that line 3 is incorrect?
FROM python:3.8 # Use official Python image as the base
WORKDIR /python_app # Set the working dir inside the con
COPY src/requirements.txt . # Copy the .txt file into the con
RUN pip install -r requirements.txt # Install Python dependencies
EXPOSE 8086 # Expose port 8086
CMD [“python”, “src/server.py”] # Run the server.py script using CMDPreformatted text
sorry for all these questions but I am kinda new to this. I am trying to understand what i am doing wrong.
You have copied only requirements.txt
into the image, but not also server.py
so it can’t be run.
There are 2 files in the src
directory - both must be placed inside the container
[root@stapp01 python_app]# ls -l src/
total 8
-rw-r--r-- 1 root root 5 Apr 16 03:48 requirements.txt
-rw-r--r-- 1 root root 278 Apr 16 03:48 server.py
Dockerfile
FROM python:3.8
WORKDIR /python_app
# Copy ALL files from src directory into container
COPY src/* ./
RUN pip install -r requirements.txt
EXPOSE 5001
CMD [ "python", "server.py" ]
Thank you so much for your help. I will try to run it in the morning. I will keep you posted.