Docker Community Forums

Share and learn in the Docker community.

Docker fails to find subdirectories


(C4k9c0) #1

I am following the provided tutorial to develop a python web app.

When I run

docker-compose run -d --rm --no-deps app python app.py create_db

I see my app is hosted at 192.168.99.100

However when I view the app, it looks like this:

I looked inside the Chrome Console and found resources weren’t found:

GET http://192.168.99.100/img/background.jpg 404 (NOT FOUND)

What is confusing is that my Dockerfile is set up to copy all my local files (including the img directory) into the src directory.

ADD . /src
WORKDIR /src

My question is this,

Why are my pages unable to find their dependencies? If /src is set as the working directory, why isn’t my container able to find the img directory?

Thanks!


(Nathan Le Claire) #2

When you run the container it looks like in the Compose file they are bind mounting ./app into /src in the container: https://github.com/getcarina/examples/blob/master/python-web-app/docker-compose.yml#L23 Does ./app in your project directory contain the correct files?

If bind mounts are specified like this, it doesn’t matter what gets baked into the container’s /src during build time. It will be over-written by whatever is in the host filesystem ./app at runtime.

The example tutorial doesn’t say anything about “NFL Crime Stats” ( https://github.com/getcarina/examples/blob/master/python-web-app/app/templates/index.html is the main page), so I’m guessing you’ve actually deviated from the tutorial material and are maybe trying to run your own app? You will need to ensure that the container can access the img directory correctly.

It’s hard to say exactly what’s wrong without more information or a reproducible example.