欧美三区_成人在线免费观看视频_欧美极品少妇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)論
主站蜘蛛池模板: 亚洲 精品 综合 精品 自拍 | 成人久久精品一区二区三区 | 亚洲免费av在线 | 精品一区二区三区在线播放 | 一本一道久久a久久精品蜜桃 | 手机看片国产免费现在观看 | 日日摸夜夜添欧美一区 | 夜夜操夜夜骑 | 国产成人啪精品视频免费网站软件 | 国产第一亚洲 | 日韩 亚洲 欧美 中文 高清 | 一区二区三区四区在线播放 | 亚洲国产系列 | 美女网站黄在线观看 | av一区二区三区在线观看 | 日日操网站| 九九热爱视频精品视频高清 | 欧美日韩精品乱国产 | 午夜亚洲一区 | 激情网五月天 | 欧美一区二区三区四区视频 | 亚洲电影免费观看高清完整版在线观 | 亚洲一级视频在线观看 | 久久午夜影视 | 欧美高清色视频在线播放 | 五月天色婷婷在线 | 一区二区三区亚洲 | 欧美在线一区二区三区欧美 | 久久综合久色欧美综合狠狠 | 久久亚洲AV成人无码电影A片 | www.欧美在线 | 婷婷激情五月综合 | 国产精品亚洲成在人线 | 成人精品鲁一区一区二区 | 国产乱码精品一区二区三区中 | 午夜资源网 | 国产福利在线观看永久免费 | 亚洲小视频在线播放 | 久久草在线视频国产一 | 国产αv | 久久精品中文 |