欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Dockerfile構(gòu)建一個(gè)Python Flask 鏡像

 更新時(shí)間:2022年01月21日 10:20:47   作者:小葉柏杉 ?  
這篇文章主要介紹了Dockerfile構(gòu)建一個(gè)Python Flask 鏡像,對(duì)正在學(xué)習(xí)的你有一定的參考價(jià)值,需要的小伙伴可以參考一下

1.Python 程序

from flask import Flask

app = Flask(__name__)


@app.route('/')
def hello_world():
? ? return 'Hello, World!'
?

2.Dockerfile

FROM python:3.9.5-slim

COPY app.py /src/app.py

RUN pip install flask

WORKDIR /src
ENV FLASK_APP=app.py

EXPOSE 5000

CMD ["flask", "run", "-h", "0.0.0.0"]
?

3.開始構(gòu)建一個(gè)小的demo

PS E:\images> docker image build -f .\flask_dockerfile -t flask_py .
[+] Building 80.3s (9/9) FINISHED
?=> [internal] load build definition from flask_dockerfile ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0.0s
?=> => transferring dockerfile: 38B ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?0.0s
?=> [internal] load .dockerignore ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?0.0s
?=> => transferring context: 2B ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?0.0s
?=> [internal] load metadata for docker.io/library/python:3.9.5-slim ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?12.7s
?=> [internal] load build context ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?0.0s
?=> => transferring context: 152B ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?0.0s
?=> [1/4] FROM docker.io/library/python:3.9.5-slim@sha256:9828573e6a0b02b6d0ff0bae0716b027aa21cf8e59ac18a76724d2 ?47.4s
?=> => resolve docker.io/library/python:3.9.5-slim@sha256:9828573e6a0b02b6d0ff0bae0716b027aa21cf8e59ac18a76724d21 ?0.0s
?=> => sha256:f42d92068b29045b6893da82032ca4fcf96193be5dcbdcfcba948489efa9e832 1.37kB / 1.37kB ? ? ? ? ? ? ? ? ? ? 0.0s
?=> => sha256:c71955050276b1e3b4be7e29089e4babeb39957981d162a3d422e084601105d3 7.63kB / 7.63kB ? ? ? ? ? ? ? ? ? ? 0.0s
?=> => sha256:b4d181a07f8025e00e0cb28f1cc14613da2ce26450b80c54aea537fa93cf3bda 27.15MB / 27.15MB ? ? ? ? ? ? ? ? ?44.7s
?=> => sha256:a1111a8f2ec3f3a8ee44a123047349a70f87d1cfebb9e48b06520d0eed436a71 2.77MB / 2.77MB ? ? ? ? ? ? ? ? ? ? 9.3s
?=> => sha256:445d04774519ca200f5c48fd028beaafb49ca763dd58767f1ae7e3933306394c 10.93MB / 10.93MB ? ? ? ? ? ? ? ? ?32.9s
?=> => sha256:9828573e6a0b02b6d0ff0bae0716b027aa21cf8e59ac18a76724d216bab7ef04 1.86kB / 1.86kB ? ? ? ? ? ? ? ? ? ? 0.0s
?=> => sha256:24f3f85d41f368fc2dcd569b181ef6cd4c2bee419a32853be2f8c8964cee34af 235B / 235B ? ? ? ? ? ? ? ? ? ? ? ?11.9s
?=> => sha256:d299f7fb612d59c3d87fcb17028a25c02e94722ef6235e60537a12d0e312abfc 2.64MB / 2.64MB ? ? ? ? ? ? ? ? ? ?17.4s
?=> => extracting sha256:b4d181a07f8025e00e0cb28f1cc14613da2ce26450b80c54aea537fa93cf3bda ? ? ? ? ? ? ? ? ? ? ? ? ?1.3s
?=> => extracting sha256:a1111a8f2ec3f3a8ee44a123047349a70f87d1cfebb9e48b06520d0eed436a71 ? ? ? ? ? ? ? ? ? ? ? ? ?0.2s
?=> => extracting sha256:445d04774519ca200f5c48fd028beaafb49ca763dd58767f1ae7e3933306394c ? ? ? ? ? ? ? ? ? ? ? ? ?0.5s
?=> => extracting sha256:24f3f85d41f368fc2dcd569b181ef6cd4c2bee419a32853be2f8c8964cee34af ? ? ? ? ? ? ? ? ? ? ? ? ?0.0s
?=> => extracting sha256:d299f7fb612d59c3d87fcb17028a25c02e94722ef6235e60537a12d0e312abfc ? ? ? ? ? ? ? ? ? ? ? ? ?0.2s
?=> [2/4] COPY app.py /src/app.py ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?0.1s
?=> [3/4] RUN pip install flask ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 19.8s
?=> [4/4] WORKDIR /src ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0.0s
?=> exporting to image ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 0.2s
?=> => exporting layers ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?0.2s
?=> => writing image sha256:0567a371be3f084fb413092b480735083c224023f8801fc723e228a021ea54b1 ? ? ? ? ? ? ? ? ? ? ? 0.0s
?=> => naming to docker.io/library/flask_py
?PS E:\images> docker images
REPOSITORY ? ? ? ? ? ?TAG ? ? ? IMAGE ID ? ? ? CREATED ? ? ? ? ?SIZE
flask_py ? ? ? ? ? ? ?latest ? ?0567a371be3f ? 10 minutes ago ? 125MB
PS E:\images> docker container run -d ?-p 5000:5000 0567a371be3f
ceb69c7ce778ebcf48a0ad91eb16902814cb20470ddb16d0ba795baa18cf4b01

訪問瀏覽器本地ip:http://127.0.0.1:5000/ 顯示Hello, World!

查看容器日志:

PS E:\images> docker logs ceb69c7ce778
?* Serving Flask app 'app.py' (lazy loading)
?* Environment: production
? ?WARNING: This is a development server. Do not use it in a production deployment.
? ?Use a production WSGI server instead.
?* Debug mode: off
?* Running on all addresses.
? ?WARNING: This is a development server. Do not use it in a production deployment.
?* Running on http://172.17.0.2:5000/ (Press CTRL+C to quit)
PS E:\images> docker logs ceb69c7ce778
?* Serving Flask app 'app.py' (lazy loading)
?* Environment: production
? ?WARNING: This is a development server. Do not use it in a production deployment.
? ?Use a production WSGI server instead.
?* Debug mode: off
?* Running on all addresses.
? ?WARNING: This is a development server. Do not use it in a production deployment.
?* Running on http://172.17.0.2:5000/ (Press CTRL+C to quit)
172.17.0.1 - - [13/Jan/2022 08:50:31] "GET / HTTP/1.1" 200 -
172.17.0.1 - - [13/Jan/2022 08:50:31] "GET /favicon.ico HTTP/1.1" 404 -

到此這篇關(guān)于Dockerfile構(gòu)建一個(gè)Python Flask 鏡像的文章就介紹到這了,更多相關(guān)Dockerfile構(gòu)建一個(gè)Python Flask 鏡像內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Python模塊搜索概念介紹及模塊安裝方法介紹

    Python模塊搜索概念介紹及模塊安裝方法介紹

    這篇文章主要介紹了Python模塊搜索概念介紹及模塊安裝方法介紹,本文詳細(xì)講解了import模塊的運(yùn)作原理,搜索路徑的過程以及模塊安裝的多種方法,需要的朋友可以參考下
    2015-06-06
  • 一文讓你秒懂精通pip并快速體驗(yàn)深度學(xué)習(xí)應(yīng)用【建議收藏】

    一文讓你秒懂精通pip并快速體驗(yàn)深度學(xué)習(xí)應(yīng)用【建議收藏】

    在使用python的時(shí)候,經(jīng)常使用到pip這個(gè)工具,可以很方便的線上安裝依賴庫(kù),當(dāng)然pip還有很多參數(shù)都可以幫我們?nèi)ゲ樵円恍?kù)信息,這篇文章主要給大家介紹了如何通過一篇文章讓你秒懂精通pip并快速體驗(yàn)深度學(xué)習(xí)應(yīng)用的相關(guān)資料,需要的朋友可以參考下
    2021-08-08
  • PyQt5每天必學(xué)之單行文本框

    PyQt5每天必學(xué)之單行文本框

    這篇文章主要為大家詳細(xì)介紹了PyQt5每天必學(xué)之單行文本框的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2018-04-04
  • python中pylint使用方法(pylint代碼檢查)

    python中pylint使用方法(pylint代碼檢查)

    Pylint 提供了簡(jiǎn)單的方式來分析 Python 代碼,其高可配置性很容易使一個(gè)部門的人員使用統(tǒng)一的代碼風(fēng)格。 本文將通過理論介紹和示例分析闡述如何 Pylint 來規(guī)范 Python 代碼
    2018-04-04
  • python中os和sys模塊的區(qū)別與常用方法總結(jié)

    python中os和sys模塊的區(qū)別與常用方法總結(jié)

    這篇文章主要給大家介紹了關(guān)于python中os和sys模塊的區(qū)別與常用方法的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧。
    2017-11-11
  • python腳本實(shí)現(xiàn)xls(xlsx)轉(zhuǎn)成csv

    python腳本實(shí)現(xiàn)xls(xlsx)轉(zhuǎn)成csv

    這篇文章主要介紹了python腳本實(shí)現(xiàn)xls(xlsx)轉(zhuǎn)成csv的相關(guān)資料,需要的朋友可以參考下
    2016-04-04
  • Python關(guān)于抽獎(jiǎng)系統(tǒng)的思考與設(shè)計(jì)思路

    Python關(guān)于抽獎(jiǎng)系統(tǒng)的思考與設(shè)計(jì)思路

    這篇文章主要介紹了Python關(guān)于抽獎(jiǎng)系統(tǒng)的思考與設(shè)計(jì)思路,本文通過一些簡(jiǎn)單的例子來說一說抽獎(jiǎng)系統(tǒng)背后的邏輯,看看究竟是你運(yùn)氣不好還是系統(tǒng)邏輯在作怪,需要的朋友可以參考下
    2023-03-03
  • Python paramiko 模塊淺談與SSH主要功能模擬解析

    Python paramiko 模塊淺談與SSH主要功能模擬解析

    這篇文章主要介紹了Python paramiko 模塊詳解與SSH主要功能模擬,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-02-02
  • Cython編譯python為so 代碼加密示例

    Cython編譯python為so 代碼加密示例

    今天小編就為大家分享一篇Cython編譯python為so 代碼加密示例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧
    2019-12-12
  • 詳解anaconda離線安裝pytorchGPU版

    詳解anaconda離線安裝pytorchGPU版

    這篇文章主要介紹了詳解anaconda離線安裝pytorchGPU版,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-09-09

最新評(píng)論