1

I am trying to create a build of a webapp I have created using Docker, but I have had no success. I've tried to follow two different tutorials but neither worked for me

Following Tutorial 1: The build seemed to complete without any problems but I could not find the image file anywhere, and 'sudo docker ps -a' returned nothing.

Following through thtutorial 2: I am now getting another error, that the requirements file is not found. I looked up solutions to that here, but it seems I am doing the correct thing by adding it to the build with the 'ADD requirements.txt /webapp' command. I checked that I spelled requirements right, haha. Now I do see it in 'sudo docker ps -a', but I dont see any image file and presumably it would not work if I did, since it could not find the requirements.

I'm quite confused as to what is wrong and how I should properly build a docker. How to I get it to find the requirements file, and then upon completing the "Build" command, actually have an image. Where is this image stored?

Below is the setup I have after following the second tutorial.

Dockerfile

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

# 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", "0.0.0.0:8000", "--module", "app:app", "--processes", "1", "--threads", "8"]
CMD ["app.py"]

Requirements

Flask==0.12.1
itsdangerous==0.24
Jinja2==2.8
MarkupSafe==0.23
Werkzeug==0.11.5
SQLite3==3.18.0

Directory Structure (if it matters)

app.py
image_data.db
README.txt
requirements.txt
Dockerfile
templates
 - index.html
static/
 - image.js
 - main.css
 img/
   - camera.png
 images/
   - empty

Current output of ' sudo docker ps -a'

CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS                      PORTS               NAMES
663d4e096938        8f5126108354        "/bin/sh -c 'pip i..."   17 minutes ago      Exited (1) 17 minutes ago                       admiring_agnesi
Brian C
  • 1,333
  • 3
  • 19
  • 36

1 Answers1

2

The requirements.txt should be in the same directory as your dockerfile exists. I see from the dockerfile that the requirements.txt is added to webapp but the

RUN pip install -r requirements.txt

is trying to find it in the current directory; You probably need to copy rquirement.txt to the current directory like

ADD requirements.txt .

Lets see if that works. I did not test it.

You can see the images by

docker images 

and then run it like

docker run -t image_name
salehinejad
  • 7,258
  • 3
  • 18
  • 26
  • if you display images using docker images, does that mean the image created is not an actual file that you can see in your directory? If so, where/how does the image get stored? – Brian C Apr 24 '17 at 18:32
  • @BrianC: Images are stored in `/var/lib/docker`. It's recommended that you don't go messing around with anything in that directory unless you want to risk breaking Docker. – jwodder Apr 24 '17 at 18:37
  • 1
    It is in /var/lib/docker as mentioned by @jwodder. You can find out more about it here: http://stackoverflow.com/questions/19234831/where-are-docker-images-stored-on-the-host-machine – salehinejad Apr 24 '17 at 19:49
  • So that worked in that it now compiles, I did a build using `docker build -t imgcomparer .` but running `docker run -t imgcomparer` gives errors like `Unable to find image 'imgcomparer:latest' locally`. I was able to get it run by instead using the ID shown by `docker images`. So it runs with the cmd `docker run -t 7b4f475bd3fe`... (or I think it does, It says `root@bbbca1d2760f:/#` in the powershell window) but now I don't get any response if I navigate to the address I specified in Docker (0.0.0.0:8000). Would it matter that the flask python file put it to the address 172.0.0.1:8000? – Brian C Apr 24 '17 at 23:35
  • @BrianC Actually I think you should set it to 127.0.0.1:xxxxx if you are on localhost in Ubuntu. I know that works for Django; should be the same for Flask. – salehinejad Apr 25 '17 at 00:11
  • Hmmm... I'm now seeing another error message at 10/15 steps: 'error processing tar file(exit status 1): Error setting up pivot dir: ...(some path)... is not a directory' – Brian C Apr 25 '17 at 04:28