How to run Python Scripts on Mac Terminal using Docker with Tensorflow?

I just got a Mac and shifted from Windows and installed Tensorflow using Docker and everything is working fine, but I want to run a python script that I have from before. Is there any way to run a python script in docker on a Mac, using the terminal?

  • Error while pushing a Docker image into Cloud Foundry
  • How to map hyperledger fabric peers (2nd, 3rd , 4th) with ports for REST communication
  • Docker container with Neo4j 2.3 enterprise edition exits without error message when mounting graph.db volume
  • Docker minimum kernel version 3.8.13 or 3.10
  • Calling mongodump wrapped into docker
  • How to run maven test with mysql running in docker
  • How to persist MongoDB data between container restarts?
  • Docker container from image created by build: is working but not working from pulled image
  • Vagrant + Docker + Postgresql - Cannot connect from host
  • Setting a policy for RabbitMQ as a part of Dockerfile process
  • Docker Exposing ports for Flask API
  • What is the best practices of using Docker for front end development on OS X and passthrough ENV from host to container
  • 3 Solutions collect form web for “How to run Python Scripts on Mac Terminal using Docker with Tensorflow?”

    Something like the below should do…

    Create a Dockerfile with the below content:

    COPY /usr/bin/
    CMD ["python", "/usr/bin/"]

    build the image:

    $ docker build -t mytensorflow .

    run it:

    $ docker run -it --rm mytensorflow

    if you want to keep the container going after the script is run don’t –rm it…

    More information would be very helpful, but perhaps this is useful for you.

    It depends on a lot of different factors, but assuming a couple of things:

    The docker containing Tensorflow has a name like ‘tensorflow’ already contains the python script:
    you can use:
    docker run tensorflow ‘python ‘

    If the script is not yet present, you can either use build a docker based on that image using a docker file, something along the lines of:

    FROM tensorflow:latest
    ADD /some/local/ /the/path/on/my/docker

    Or you can create/run the docker interactively by doing something along the lines of:

    Docker run -ti tensorflow /bin/bash
    Which will start an instance of the tensorflow container and start /bin/bash on it.
    You now have an interactive shell so can place the python script any way you want and start it.

    Lets assume you have a script located at /Users/awesome_user/python_scripts/ on your mac

    By default the tensorFlow image bash will locate you at /notebooks.

    Run this command in your terminal:

    docker run --rm -it -v /Users/awesome_user/python_scripts/:/notebooks bash

    This will map your local mac folder /Users/awesome_user/python_scripts/ to the docker’s local folder /notebooks

    then just run from the bash python Also running ls should reveal your folder content

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