如何使用Docker与Tensorflow在Mac终端上运行Python脚本?

问题描述:

我刚刚从Mac转移到Windows,并使用Docker安装了Tensorflow,并且一切正常,但是我想要运行一个我以前的python脚本。有没有办法使用终端在Mac上的docker中运行python脚本?

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?

...

创建具有以下内容的Docker文件:

Create a Dockerfile with the below content:

FROM gcr.io/tensorflow/tensorflow:latest
COPY script.py /usr/bin/
CMD ["python", "/usr/bin/script.py"]

构建图像:

$ docker build -t mytensorflow .

运行它:

$ docker run -it --rm mytensorflow

如果你想保留运行脚本后的容器不要--rm它...

if you want to keep the container going after the script is run don't --rm it...