Docker IO Error with local js file

I am having hard time loading local js file with docker. I had no problem testing on local machine but if I host it on web server running on docker No such file or directory: 'static/js/data.js error.

My code is organized as follow:

  • Figure out IP address within docker container
  • php significant slower on docker then kvm
  • Database with starttime and endtime [closed]
  • Creating a CAAS using Kubernetes/Docker/Flannel/etcd
  • Will istio add support for docker swarm?
  • Piping docker run container ID to docker exec
  • Root/

    And in I am generating the file data.js and from index.html I read the file data.js with no problem <script src="../static/js/data_data.js"></script>

    And in I create a file using file = open("static/js/data.js", "w+") which works fine in local machine but not in web server (EC2)

    And here’s my dockerfile

    FROM ubuntu:14.04
    RUN apt-get update
    RUN apt-get install python-setuptools -y && DEBIAN_FRONTEND=noninteractive apt-get install python-setuptools -y 
    RUN apt-get install python-pip -y
    RUN apt-get install python-numpy -y
    RUN apt-get install python-matplotlib -y
    RUN apt-get install python-mysqldb -y
    RUN apt-get install libpq-dev -y
    RUN apt-get install python-psycopg2 -y
    RUN apt-get install python-pandas -y
    RUN pip install flask
    ADD . /src
    # Expose
    EXPOSE  80
    # Run
    CMD ["python", "/src/"]

  • What are the disadvantages of a Docker container using the host network?
  • Docker commit doesn't save the changed state of my container
  • edit docker container files with OS X Sublime Text
  • docker volumes does not work
  • Running jenkins on docker to simulate red hat linux
  • Docker 1.12 Swarm Overlay Network Published Port
  • One Solution collect form web for “Docker IO Error with local js file”

    The problem is that you didn’t specify an absolute link in your application.

    You can easily reproduce this problem on your local by doing

    cd /
    python /<pathtosrc>/src/

    Docker work directory is / by default.

    So when you try to execute your program, it search for /static/js/data.js. but it doesn’t exist.

    You can solve the problem by using an absolute link, or by changing Docker work directory in your Dockerfile. Just add the following line at the end

    # Run
    CMD ["python", "/src/"]
    WORKDIR /src

    Remember that WORKDIR will change the work directory for every command run after the WORKDIR line

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