2017-05-27 109 views
0

我跟着一些在线泊坞窗的教程,我写了这Dockerfile如何在Mac OS上运行python-flask容器?

FROM python:3.5-slim 

WORKDIR /opt 

COPY requirements.txt /opt/requirements.txt 
RUN pip install -r /opt/requirements.txt 

COPY hello.py /opt/hello.py 

EXPOSE 5000 

CMD ["python", "/opt/hello.py"] 

我建我的形象有:docker build -t ciasto/pythonflask:v1 .

,导致:

$ docker build -t ciasto/pythonflask:v1 . 
Sending build context to Docker daemon 4.096 kB 
Step 1/7 : FROM python:3.5-slim 
3.5-slim: Pulling from library/python 
10a267c67f42: Already exists 
f68a39a6a5e4: Pull complete 
fb30faeeb5d1: Pull complete 
b6ab8c11f85f: Pull complete 
69739f677b7a: Pull complete 
Digest: sha256:6cbef17164fc35bed1f43b8cb671c51f5622881008fd748eaf80c20e7bfc0079 
Status: Downloaded newer image for python:3.5-slim 
---> b27a94c44674 
Step 2/7 : WORKDIR /opt 
---> a7724a7ac155 
Removing intermediate container 356124f40ff1 
Step 3/7 : COPY requirements.txt /opt/requirements.txt 
---> 9fd790ec548d 
Removing intermediate container 8ba92114cd28 
Step 4/7 : RUN pip install -r /opt/requirements.txt 
---> Running in d23ef61ca5fc 
Collecting Flask==0.10.1 (from -r /opt/requirements.txt (line 1)) 
    Downloading Flask-0.10.1.tar.gz (544kB) 
Collecting Werkzeug>=0.7 (from Flask==0.10.1->-r /opt/requirements.txt (line 1)) 
    Downloading Werkzeug-0.12.2-py2.py3-none-any.whl (312kB) 
Collecting Jinja2>=2.4 (from Flask==0.10.1->-r /opt/requirements.txt (line 1)) 
    Downloading Jinja2-2.9.6-py2.py3-none-any.whl (340kB) 
Collecting itsdangerous>=0.21 (from Flask==0.10.1->-r /opt/requirements.txt (line 1)) 
    Downloading itsdangerous-0.24.tar.gz (46kB) 
Collecting MarkupSafe>=0.23 (from Jinja2>=2.4->Flask==0.10.1->-r /opt/requirements.txt (line 1)) 
    Downloading MarkupSafe-1.0.tar.gz 
Building wheels for collected packages: Flask, itsdangerous, MarkupSafe 
    Running setup.py bdist_wheel for Flask: started 
    Running setup.py bdist_wheel for Flask: finished with status 'done' 
    Stored in directory: /root/.cache/pip/wheels/b6/09/65/5fcf16f74f334a215447c26769e291c41883862fe0dc7c1430 
    Running setup.py bdist_wheel for itsdangerous: started 
    Running setup.py bdist_wheel for itsdangerous: finished with status 'done' 
    Stored in directory: /root/.cache/pip/wheels/fc/a8/66/24d655233c757e178d45dea2de22a04c6d92766abfb741129a 
    Running setup.py bdist_wheel for MarkupSafe: started 
    Running setup.py bdist_wheel for MarkupSafe: finished with status 'done' 
    Stored in directory: /root/.cache/pip/wheels/88/a7/30/e39a54a87bcbe25308fa3ca64e8ddc75d9b3e5afa21ee32d57 
Successfully built Flask itsdangerous MarkupSafe 
Installing collected packages: Werkzeug, MarkupSafe, Jinja2, itsdangerous, Flask 
Successfully installed Flask-0.10.1 Jinja2-2.9.6 MarkupSafe-1.0 Werkzeug-0.12.2 itsdangerous-0.24 
---> 775e776b6838 
Removing intermediate container d23ef61ca5fc 
Step 5/7 : COPY hello.py /opt/hello.py 
---> 19591aa43188 
Removing intermediate container 72a6ba817af0 
Step 6/7 : EXPOSE 5000 
---> Running in e40c405a1f23 
---> 3174d4ca3001 
Removing intermediate container e40c405a1f23 
Step 7/7 : CMD python /opt/hello.py 
---> Running in 6da3612345ae 
---> 5504685771d5 
Removing intermediate container 6da3612345ae 
Successfully built 5504685771d5 
macHost:pythonflask$ 

当我做docker ps -a我什么也没得到。我做错了什么?我甚至没有得到任何错误。我在Mac OS Sierra上。

$ docker -v 
Docker version 1.13.1, build 092cba3 

回答

0

要使用docker查看所有构建图像的列表,请运行docker images。它应该显示您的图像的名称,然后您可以使用docker run ciasto/pythonflask:v1运行。

更多关于this linkdocker run指令。