I am trying to make a dockerfile for a python/flask webapp and keep running into issues inspite of multiple changes based off what I've read
The Dockerfile I have at present is as follows:
FROM ubuntu:latest
#Update OS
RUN sed -i 's/# \(.*multiverse$\)/\1/g' /etc/apt/sources.list
RUN apt-get update
RUN apt-get -y upgrade
# Install Python
RUN apt-get install -y python-dev python-pip
# Add requirements.txt
ADD requirements.txt /webapp
ADD requirements.txt .
# Install uwsgi Python web server
RUN pip install uwsgi
# Install app requirements
RUN pip install -r requirements.txt
# Create app directory
ADD . /webapp
# Set the default directory for our environment
ENV HOME /webapp
WORKDIR /webapp
# Expose port 8000 for uwsgi
EXPOSE 8000
ENTRYPOINT ["uwsgi", "--http", "127.0.0.1:8000", "--module", "app:app", "--processes", "1", "--threads", "8"]
#ENTRYPOINT ["python"]
CMD ["app.py"]
Attempting to run this Dockerfile with the command sudo docker build -t imgcomparer .
gives the error:
Step 10/15 : ADD . /webapp
Error processing tar file(exit status 1): Error setting up pivot dir: mkdir /var/lib/docker/aufs/mnt/53420471c832e61b7f75ac5fc5268d64b932a4d589a8464c63bf5868f127ff04/webapp/.pivot_root981494252: not a directory
After some research, I discovered that putting a trailing / at the end of the path would work (see this question and this one)
Upon doing that (and the same on the following lines) I have the following in my dockerfile:
# Create app directory
ADD . /webapp/
# Set the default directory for our environment
ENV HOME /webapp/
WORKDIR /webapp/
that gives this error:
Step 10/15 : ADD . /webapp/
stat /var/lib/docker/aufs/mnt/f37b19a8d72d39cbbdfb0bae6359aee499fab0515e2415e251a50d528708bdd3/webapp/: not a directory
Last, I tried removing the problematic line altogether. When I have
# Create app directory
# ADD . /webapp
# Set the default directory for our environment
ENV HOME /webapp
WORKDIR /webapp
The docker file successfully builds! But, unsurprisingly, trying to run it gives an error:
sudo docker run -t imgcomparer
docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "chdir to cwd (\"/webapp\") set in config.json failed: not a directory"
: Are you trying to mount a directory onto a file (or vice-versa)? Check if the specified host path exists and is the expected type.
Directory Structure is as follows
app.py
image_data.db
README.txt
requirements.txt
Dockerfile
templates
- index.html
static/
- image.js
- main.css
img/
- camera.png
images/
- empty
RUN mkdir /webappmkdir: cannot create directory '/webapp/': File existsADD requirements.txt /webapp, which is probably creating a file calledwebapp. Therefore, you can't then treat it as a directorypythontag applies to this questionADD requirements.txtline and now it builds... but it does not run! I get an error thatimgcomparer unable to load configuration from app.py