How do I run a python script with Tensorflow running in a Docker on Windows?

Imagine I manage to install Tensorflow on Windows, using Docker as in these two links, for example:

TensorFlow on Windows

  • Flask app doesn't retrieve data from same database as unit tests
  • Docker Swarm, Compose and PostgreSQL
  • Using netcat to pipe unix socket to tcp socket
  • Docker build fails with Hash Sum Mismatch error [closed]
  • docker-compose: difference between network and link
  • Failure - Authentication is required to pull public docker images from Dockerhub registry
  • How to install and run TensorFlow on a Windows PC

    In both links, they’re able to use Tensorflow on a shell python (don’t know exactly what version, I have Anaconda installed).

    But what if I want to run a script that I made on my local machine that has Tensorflow in it? How do I call the script from docker? I mean, how do I find the script (located on my desktop, for instance) from docker to run it?

  • How to use stdin, stdout and stderr streams after attaching to a container using Docker api?
  • /var/run/docker.sock: no such file or directory. Are you trying to connect to a TLS-enabled daemon without TLS?
  • Docker tomcat7 container cannot connect to host activemq
  • Can't run Ecplise Che under ubuntu
  • How can I expose a Docker container port only to localhost so that it is also accessible via an ssh tunnel?
  • Docker: Creating a data volume container vs simply using the -v flag with `run`?
  • One Solution collect form web for “How do I run a python script with Tensorflow running in a Docker on Windows?”

    If you want your container (that has Tensorflow already preinstalled, since it is running from the Tensorflow image) to access your script, you need to mount that script from your host onto a local path in your container.

    docker run -v /path/to/your/script:/path/to/script
    

    See “Mount a host file as a data volume”.

    The -v flag can also be used to mount a single file – instead of just directories – from the host machine.

    $ docker run --rm -it -v ~/.bash_history:/.bash_history ubuntu /bin/bash
    

    Then, from your container, you will access the same script in /path/to/script.

    Alex Pryiomka gives an example of running such a script in tensorflow with “How to run Python Scripts on Mac Terminal using Docker with Tensorflow?”

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