简体   繁体   中英

How to run a python-flask container on Mac OS?

I followed some online Docker tutorial and I wrote this Dockerfile :

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"]

I built my image with: docker build -t ciasto/pythonflask:v1 .

that resulted in:

$ 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$

When I do docker ps -a I get nothing. What did I do wrong? I am not even getting any error. I am on Mac OS Sierra.

$ docker -v
Docker version 1.13.1, build 092cba3

To see the list of all built images with docker, run docker images . It should show the name of your image which you can then run with docker run ciasto/pythonflask:v1 .

More about docker run command on this link .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM