欧美三区_成人在线免费观看视频_欧美极品少妇xxxxⅹ免费视频_a级毛片免费播放_鲁一鲁中文字幕久久_亚洲一级特黄

2019-09-18 Docker 安裝Python 3.7.4

系統(tǒng) 1672 0

要安裝運(yùn)行Python的容器,那先到https://hub.docker.com/去查找一下,看看有哪些可用的鏡像。
恩,最高的版本已經(jīng)是3.8.0b4了,不過考慮下還是安裝3.7.4穩(wěn)定版把。
用來安裝的虛擬機(jī)是Ubuntu 18.04服務(wù)器版,安裝虛擬機(jī)就跳過不寫了,太簡單。
為了方便,使用root用戶操作。
在Ubuntu上安裝Docker
使用官方腳本,在終端輸入

          
            curl -fsSL get.docker.com -o get-docker.sh

          
        

瞬間下載安裝腳本:

          
            -rw-r--r-- 1 root  root  13185 Sep 18 12:30 get-docker.sh

          
        

執(zhí)行一下

          
            root@ubuntu:~# sh get-docker.sh

          
        

很快的,安裝完了。啟動(dòng)docker服務(wù):

          
            systemctl start docker
systemctl status docker

          
        

可以看到,docker服務(wù)已經(jīng)在運(yùn)行了,設(shè)置開機(jī)啟動(dòng)用systemctl enable docker。

          
            root@ubuntu:~# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2019-09-18 12:56:23 UTC; 9h ago
     Docs: https://docs.docker.com
 Main PID: 30874 (dockerd)
    Tasks: 10
   CGroup: /system.slice/docker.service
           └─30874 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

          
        

試運(yùn)行一下docker hello-world,第一次會(huì)提示 "Unable to find image 'hello-world:latest' locally", 然后從docker hub去下載鏡像到本地。
再次運(yùn)行,出現(xiàn)下面提示,運(yùn)行成功。

          
            root@ubuntu-1804-102:~# docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

          
        

檢查一下鏡像, docker image ls, 可以看到hello-world已經(jīng)在本地了

          
            REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
hello-world         latest              fce289e99eb9        8 months ago        1.84kB

          
        

下載python 3.7.4鏡像,需要幾分鐘,看網(wǎng)速,因?yàn)楣俜界R像有900M多

          
            docker pull python:3.7.4

          
        

看下鏡像列表:

          
            root@ubuntu:~# docker image ls
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
python              3.7.4               02d2bb146b3b        6 days ago          918MB
hello-world         latest              fce289e99eb9        8 months ago        1.84kB

          
        

運(yùn)行容器

          
            root@ubuntu:~# docker run  -p 8000:8000  -i -t  -v /data/www/:/www python:3.7.4 /bin/bash
root@c6baa2eb898c:/#

          
        

這里 -p 參數(shù)表示發(fā)布端口號(hào)到主機(jī), -i -t 或者 -it 表示交互式容器, -v /data/www/:/www 表示把主機(jī)上/data/www目錄映射到容器的/www目錄下。
交互模式下,使用exit即可退出, 如果想讓容器一直運(yùn)行,則可以添加-d參數(shù)。

          
            root@ubuntu:~# docker run  -p 8000:8000  -i -t -d -v /data/www/:/www python:3.7.4 /bin/bash
e21ad1ec196836fb61aea72a1b811376312d935c152b7d17eb425b8e8015da02

          
        

啟動(dòng)/停止容易,以及在交互模式運(yùn)行hello world程序。

          
            root@ubuntu:~# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED              STATUS              PORTS                    NAMES
e21ad1ec1968        python:3.7.4        "/bin/bash"         About a minute ago   Up About a minute   0.0.0.0:8000->8000/tcp   vigorous_wescoff
root@ubuntu:~# docker stop e21ad1ec1968
e21ad1ec1968
root@ubuntu:~# docker run  -p 8000:8000  -i -t  -v /data/www/:/www python:3.7.4 /bin/bash
root@f292060243d7:/# cd /www
root@f292060243d7:/www# python3 hello.py
Hello World!
root@f292060243d7:/www#

          
        

常用命令:

          
            啟動(dòng)容器:docker run <參數(shù)>
停止容器:docker stop <參數(shù)>
查看容器:docker ps 
刪除容器:docker rm <容器>
查看鏡像:  docker image ls
刪除鏡像:docker image rm <鏡像>
#刪除鏡像可以使用鏡像名,即<倉庫名>:<標(biāo)簽>
#可以使用長id,短id(長id的前3位)
#可以使用鏡像摘要: docker image ls --digests
root@ubuntu:~# docker image ls --digests
REPOSITORY          TAG                 DIGEST                                                                    IMAGE ID            CREATED             SIZE
python              3.7.4               sha256:0f0e991a97426db345ca7ec59fa911c8ed27ced27c88ae9966b452bcc6438c2f   02d2bb146b3b        6 days ago          918MB
#使用摘要更精確的刪除 docker image rm 
            
              @DIGEST

            
          
        

如何保存容器的更改:
發(fā)現(xiàn)需要使用pip安裝模塊,但安裝完后重新運(yùn)行容器發(fā)現(xiàn)新裝的模塊并沒有保存,這是因?yàn)闆]有commit。
在docker容器交互界面安裝完以后,另開一個(gè)窗口到本機(jī),查看運(yùn)行中的容器:

          
            root@ubuntu:~# docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
4931cfd2b692        python:3.7.4        "/bin/bash"         2 minutes ago       Up 2 minutes                            crazy_nightingale

          
        

記錄下Container ID, 提交一下

          
            root@ubuntu:~# docker commit 4931cfd2b692 python:3.7.4
sha256:636bf7a28bc7057c8c3b60fe5c736b32bb87b8af0e1b0328b1c28ded8245d7f0

          
        

再登錄容器交互界面,發(fā)現(xiàn)前面的更改已經(jīng)保存了。


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點(diǎn)擊下面給點(diǎn)支持吧,站長非常感激您!手機(jī)微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點(diǎn)擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動(dòng)力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 香港三级台湾三级在线播放徐 | 亚洲精品国产精品国自产在线 | 玖玖啪 | 日韩欧美不卡 | 九九国产在线视频 | 一区二区三区亚洲 | 亚洲视频在线网站 | 大喷水吹潮magnet | 久久一日本道色综合久久 | 久久综合婷婷香五月 | 深夜日韩 | av在线电影网站 | 免费国产精品视频在线 | 精品亚洲欧美高清不卡高清 | 国产在线91精品入口首页 | 亚洲日本在线天堂无码 | 夜夜爽夜夜叫夜夜高潮漏水 | 日韩在线播放网址 | 日本一区二区三区四区高清视频 | 欧美午夜影院 | 日韩精品不卡 | 久久久国产一级片 | 日本一区午夜爱爱 | 成人视品 | 999毛片免费观看 | 九色视频网址 | 天天操天天干天天操 | jizzjizzjizz欧美 | 天天拍天天操 | 成人欧美一区二区三区在线播放 | 92精品国产自产在线 | 欧美性猛交一区二区三区精品 | 麻豆网址| 91精品久久久久久久久久小网站 | 九九热免费视频在线观看 | 精品欧美一区二区在线观看 | 久草欧美视频 | 黄色一级大片在线免费看产 | 日日碰碰 | 极品逼| 国产精品俺来也在线观看 |