Docker Community Forums

Share and learn in the Docker community.

No such file or directory after building the image


#1

I just started going through the tutorial and trying to wrap up some of my codes into the docker. The question might sound familiar to many of you as I can see quite similar threat but unfortunately I couldn’t get my heads around so decided to write it here.

I have made a telegram chatbot using python. All files are under /project/ . I have another folder under /project/ calledDockerTelegramChatBot` where I have the Dockerfile.

Inside the DockerTelegramChatbot I have two files the Dockerfile and requirements.txt.

The content of the Dockerfile looks like the following

# Use an official Python runtime as a parent image
FROM python:3.6-stretch

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
COPY . /app
ADD . .

# Install any needed packages specified in requirements.txt
RUN pip install -r requirements.txt --default-timeout=100

# Make port 80 available to the world outside this container
EXPOSE 80

# Run app.py when the container launches
CMD pwd

CMD ls
CMD python /app/main_bot.py

I build the image using

docker build -t simpletelegramchatbot DockerTelegramChatBot/

and run it with

docker run -p 4000:80 simpletelegramchatbot

The main question is how I can resolve the “No such file or directory after building the image”. But also, I wonder what is the best practice to troubleshoot such cases, if I edit the dockerfile, do I have to build it from scratch every time ? “pip install requirements” takes a few minutes and makes the whole process quite annoying.

I appreciate your assistance