Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Introduction to Docker Why Docker? Why Should You Use Docker?

COPY failed: file not found in build context or excluded by .dockerignore: stat app.py: file does not exist

I get an error when I run the docker build command. lucard@USHA:~/MyDockerContainers/PythonWebServer$ docker build -t web-app . Sending build context to Docker daemon 2.048kB Step 1/9 : FROM ubuntu:latest ---> 27941809078c Step 2/9 : RUN apt-get update -y ---> Using cache ---> 35c89d12da8c Step 3/9 : RUN apt-get install -y python3 ---> Using cache ---> 923ed7428ee3 Step 4/9 : ENTRYPOINT ["python3"] ---> Using cache ---> e8e28a145519 Step 5/9 : CMD ["app.py"] ---> Using cache ---> 92a2d00bfe4e Step 6/9 : WORKDIR /app ---> Using cache ---> 2715748c5744 Step 7/9 : COPY app.py app.py COPY failed: file not found in build context or excluded by .dockerignore: stat app.py: file does not exist

This is my Dockerfile

Dockerfile for building a Python web service

Pull base image.

FROM ubuntu:latest

Commands to run to install dependencies

RUN apt-get update -y RUN apt-get install -y python3

When you pass commands to the container, what should interpert them

ENTRYPOINT ["python3"]

Coomand to run when the container starts.

CMD ["app.py"]

Working directory.


Copy apps from the local folder to the Docker Container

COPY app.py app.py COPY alternate.py alternate.py

Expose ports.