unable to invoke docker container

Using docker i am unable to invoke the web application from the browser.

The following is the dockerfile used:

  • Deploying and Accessing Database Inside Docker Container
  • Beneifts of line continuation in Dockerfiles
  • java.net.InetAddress java class doesn't resolve IP on Alpine Docker container
  • Docker daemon and DNS
  • why I can't ping my docker container?
  • Docker-compose run service if another service status is 0 (success)
  • FROM continuumio/anaconda:latest
    
    Expose 5000
    
    ADD . /code-directory
    
    WORKDIR code-directory
    
    RUN conda install opencv
    
    RUN pip install boto3
    
    RUN pip install boto
    
    RUN pip install flask
    RUN pip install pathlib
    
    ADD facedetection_video.py facedetection_video.py
    
    ADD UI_Interface UI_Interface
    
    WORKDIR /UI_Interface
    
    COPY . app.py
    
    RUN python app.py &
    

    The following is the contents of app.py

    from flask import Flask
    
    app = Flask(__name__)
    
    @app.route('/')
    
    def hello_world():
    
        return 'Flask Dockerized'
    
    if __name__ == '__main__':
    
        app.run(debug=True,host='0.0.0.0')
    

    The commands used to generate docker image

    docker build -t test1 .
    

    The command used to run the container

    docker run -d -p 5000:5000 test1
    

    The output status message of the container is:

    Exited (0) 3 minutes ago
    

    In the logs I could not find any error message. Pls suggest

  • nginx hangs serving video via proxy
  • What is the benefit of Docker container for a memcached instance?
  • Docker - Fail to run container from imported image with entrypoint
  • Unable to install Docker on Ubuntu 17 [closed]
  • Volume not really mounted to docker container on IBM Bluemix
  • Docker not able to connect via host IP or localhost
  • 2 Solutions collect form web for “unable to invoke docker container”

    RUN is a Dockerfile directive to run a command at build-time to generate an image.

    What you need for running the container is to define the CMD, which represents the program that will run as a container when you execute docker run ...

    Change:

    RUN python app.py &
    

    To:

    CMD python app.py
    

    The issue is resolved.

    In the dockerfile there was error changed the dockerfile as shown below:

    FROM ubuntu:16.04

    RUN mkdir -p /usr/src/app
    WORKDIR /usr/src/app

    RUN apt-get install -y libavresample-dev

    Various Python and C/build deps

    RUN apt-get update && apt-get install -y \

    wget \
    build-essential \ 
    cmake \ 
    git \
    unzip \ 
    pkg-config \
    python-dev \ 
    python-opencv \ 
    libopencv-dev \ 
    libav-tools  \ 
    libjpeg-dev \ 
    libpng-dev \ 
    libtiff-dev \ 
    libjasper-dev \ 
    libgtk2.0-dev \ 
    python-numpy \ 
    python-pycurl \ 
    libatlas-base-dev \
    gfortran \
    webp \ 
    python-opencv \ 
    qt5-default \
    libvtk6-dev \ 
    zlib1g-dev 
    

    RUN apt-get install -y python-pip

    RUN mkdir -p ~/opencv

    RUN cd ~/opencv

    RUN apt-get install -y vim

    RUN pip install boto3

    RUN pip install boto

    RUN pip install flask

    RUN pip install pathlib

    RUN pip install scikit-video

    EXPOSE 5000

    COPY . /app
    WORKDIR /app

    ENTRYPOINT [“python”]

    CMD [“app.py”]

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.