欧美三区_成人在线免费观看视频_欧美极品少妇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)論
主站蜘蛛池模板: 精品综合| 欧美高清一区二区三区欧美 | 午夜深夜福利网址 | 午夜在线免费视频 | 香蕉香蕉国产片一级一级毛片 | 国内自拍偷拍 | 久久久99精品免费观看 | 亚洲黄色免费观看 | 国产一区二区欧美 | 999久久久免费精品国产 | 99精品视频在线视频免费观看 | 拍拍拍无挡免费视频网站 | 91社区影院 | 欧美日韩精品久久久免费观看 | 成人在线免费观看 | 国产高清在线精品免费 | 久久亚洲一级毛片 | 久久久久久久久久爱 | 91看片片 | 成人在线小视频 | 婷婷色国产偷v国产偷v小说 | 午夜激情视频在线观看 | 欧美一极视频 | 国产三级在线视频播放线 | 成人av网站在线观看 | 114美女做爰视频在线 | 欧美日韩国产在线人成dvd | 日韩综合| 九九视频精品全部免费播放 | 国产在线播放免费 | 久久综合丝袜日本网 | 久久免费视频一区 | 谍影特工在线观看完整版 | 欧美激情一区二区三级高清视频 | 欧美日韩国产在线 | 国产精品一区在线观看你懂的 | 日韩视频在线观看免费 | 亚洲视频一区在线 | 极色品影院 | 天天插天天射天天操 | 天天综合久久 |