日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

docker開(kāi)發(fā)_在basic image的基礎(chǔ)上創(chuàng)建自定義的

系統(tǒng) 1868 0

方法一:docker commit

1. 跑一個(gè)basic image,docker新建了一個(gè)容器

      root@ubuntu:/home/thm/docker/test# 
      
        docker run -i -t tanghuimin0713/ubuntu_amd64:14.04 /bin/
      
      
        
          bash
        
         

WARNING: Local (
      
      
        127.0
      
      .
      
        0.1
      
      ) DNS resolver found 
      
        in
      
       resolv.conf and containers can
      
        '
      
      
        t use it. Using default external servers : [8.8.8.8 8.8.4.4]
      
      

root@5d807872b2ba:/# 
    

2. 在容器內(nèi)安裝apache2

      root@5d807872b2ba:/# 
      
        apt-get
      
      
        
           update
        
        

Ign http:
      
      
        //
      
      
        archive.ubuntu.com trusty InRelease       
      
      

Hit http:
      
        //
      
      
        archive.ubuntu.com trusty Release.gpg
      
      

Hit http:
      
        //
      
      
        archive.ubuntu.com trusty Release
      
      

Hit http:
      
        //
      
      
        archive.ubuntu.com trusty/main i386 Packages
      
      

Get:
      
        1
      
       http:
      
        //
      
      
        archive.ubuntu.com trusty/main Translation-en [762 kB]
      
      

Fetched 
      
        762
      
       kB 
      
        in
      
       34s (
      
        22.1
      
       kB/
      
        s)                                                                                                              

Reading package lists... Done

root@5d807872b2ba:
      
      /
      
        # 

root@5d807872b2ba:
      
      /# 
      
        apt-get
      
      
        
           install apache2
        
        

Reading package lists... Done

Building dependency tree... Done

The following extra packages will be installed:

...

...

...
      
    

3. 退出容器,將剛才裝了apache的容器創(chuàng)建成一個(gè)新的image

      root@5d807872b2ba:/
      
        # 
        
          exit
        
          

exit

root@ubuntu:
      
      /home/thm/docker/
      
        test# 

root@ubuntu:
      
      /home/thm/docker/test# 
      
        docker ps -
      
      
        
          l
        
        

CONTAINER ID        IMAGE                               COMMAND             CREATED             STATUS              PORTS               NAMES

5d807872b2ba        tanghuimin0713
      
      /ubuntu_amd64:
      
        14.04
      
         /bin/bash           
      
        7
      
       minutes ago       Exit 
      
        0
      
      
                                          nostalgic_heisenberg   

root@ubuntu:
      
      /home/thm/docker/test# 
      
        docker commit 5d807872b2ba tanghuimin0713/ubuntu_amd64_apache2:14.04
      
      
        

e7df0b3ab526c83098d54e826b4e8e1f2c6efbe0a2511c3b06b79723bacfff52

root@ubuntu:
      
      /home/thm/docker/
      
        test# 
        
          docker images
        
        

REPOSITORY                            TAG                 IMAGE ID            CREATED             VIRTUAL SIZE

tanghuimin0713
      
      /ubuntu_amd64_apache2   
      
        14.04
      
                     e7df0b3ab526        
      
        3
      
       seconds ago       
      
        248.1
      
      
         MB

scratch                               latest              6e1aa483880d        About an hour ago   
      
      
        0
      
      
         B

tanghuimin0713
      
      /ubuntu_amd64           
      
        14.04
      
                     6cfee0d4349b        
      
        4
      
       hours ago         
      
        216.8
      
      
         MB

tanghuimin0713
      
      /ubuntu_amd64           latest              6cfee0d4349b        
      
        4
      
       hours ago         
      
        216.8
      
      
         MB

tanghuimin0713
      
      /ubuntu_i386            
      
        14.04
      
                     ee57f53fe012        
      
        5
      
       hours ago         
      
        216.8
      
      
         MB

tanghuimin0713
      
      /ubuntu_i386            latest              ee57f53fe012        
      
        5
      
       hours ago         
      
        216.8
      
      
         MB

ubuntu                                
      
      
        14.04
      
                     c4ff7513909d        
      
        9
      
       days ago          
      
        225.4
      
      
         MB

ubuntu                                trusty              c4ff7513909d        
      
      
        9
      
       days ago          
      
        225.4
      
      
         MB

ubuntu                                
      
      
        14.04
      
      .
      
        1
      
                   c4ff7513909d        
      
        9
      
       days ago          
      
        225.4
      
      
         MB

ubuntu                                latest              c4ff7513909d        
      
      
        9
      
       days ago          
      
        225.4
      
      
         MB

ubuntu                                
      
      
        14.10
      
                     75204fdb260b        
      
        9
      
       days ago          
      
        230.1
      
      
         MB

ubuntu                                utopic              75204fdb260b        
      
      
        9
      
       days ago          
      
        230.1
      
      
         MB

ubuntu                                
      
      
        12.04
      
                     822a01ae9a15        
      
        9
      
       days ago          
      
        108.1
      
      
         MB

ubuntu                                
      
      
        12.04
      
      .
      
        5
      
                   822a01ae9a15        
      
        9
      
       days ago          
      
        108.1
      
      
         MB

ubuntu                                precise             822a01ae9a15        
      
      
        9
      
       days ago          
      
        108.1
      
      
         MB

ubuntu                                
      
      
        12.10
      
                     c5881f11ded9        
      
        9
      
       weeks ago         
      
        172.2
      
      
         MB

ubuntu                                quantal             c5881f11ded9        
      
      
        9
      
       weeks ago         
      
        172.2
      
      
         MB

ubuntu                                
      
      
        13.04
      
                     463ff6be4238        
      
        9
      
       weeks ago         
      
        169.4
      
      
         MB

ubuntu                                raring              463ff6be4238        
      
      
        9
      
       weeks ago         
      
        169.4
      
      
         MB

ubuntu                                
      
      
        13.10
      
                     195eb90b5349        
      
        9
      
       weeks ago         
      
        184.7
      
      
         MB

ubuntu                                saucy               195eb90b5349        
      
      
        9
      
       weeks ago         
      
        184.7
      
      
         MB

jamtur01
      
      /puppetmaster                 latest              99200e07340a        
      
        11
      
       weeks ago        
      
        312.4
      
      
         MB

ubuntu                                
      
      
        10.04
      
                     3db9c44f4520        
      
        4
      
       months ago        
      
        183
      
      
         MB

ubuntu                                lucid               3db9c44f4520        
      
      
        4
      
       months ago        
      
        183
      
      
         MB

root@ubuntu:
      
      /home/thm/docker/test# 
    

4. run一下剛剛新創(chuàng)建的image,看看container內(nèi)是否存在剛剛安裝的apache2

      root@ubuntu:/home/thm/docker/test# 
      
        
          docker run -t -i tanghuimin0713/ubuntu_amd64_apache2:14.04 /bin/bash
        
         

WARNING: Local (
      
      
        127.0
      
      .
      
        0.1
      
      ) DNS resolver found 
      
        in
      
       resolv.conf and containers can
      
        '
      
      
        t use it. Using default external servers : [8.8.8.8 8.8.4.4]
      
      

root@081572d422c7:/
      
        # 

root@081572d422c7:
      
      /
      
        # 

root@081572d422c7:
      
      /
      
        # apache

apache2     apache2ctl  apachectl   
      
    

5. 將新創(chuàng)建的image同步到docker hub

docker push tanghuimin0713/ubuntu_amd64_apache2

?

方法二:Dockerfile

1. 在一個(gè)空目錄下創(chuàng)建Dockerfile,并在Dockerfile中寫(xiě)入如下類(lèi)似批處理的語(yǔ)句

      root@ubuntu:/home/thm/docker/
      
        test# 
        
          touch Dockerfile
        
        

root@ubuntu:
      
      /home/thm/docker/test# 
      
        vim Dockerfile 
      
    
      
        1
      
       FROM tanghuimin0713/ubuntu_amd64:
      
        14.04
      
      
        2
      
       RUN apt-
      
        get
      
      
         update

  
      
      
        3
      
       RUN apt-
      
        get
      
       install -
      
        y nginx

  
      
      
        4
      
       RUN echo 
      
        "
      
      
        Hi, I am in your container
      
      
        "
      
       > /usr/share/nginx/html/
      
        index.html

  
      
      
        5
      
       EXPOSE 
      
        80
      
    

Dockerfile中相關(guān)命令解釋?zhuān)?

FROM: 以"tanghuimin0713/ubuntu_amd64: 14.04 "為basic image運(yùn)行一個(gè)container;

RUN: 在container中執(zhí)行命令;

EXPOSE: 將鏡像的80端口暴露在外,這樣容器外可以看到這個(gè)端口并與其通信;

2. docker build創(chuàng)建image

      root@ubuntu:/home/thm/docker/
      
        test# 

root@ubuntu:
      
      /home/thm/docker/test# 
      
        docker build -t="tanghuimin0713/ubuntu_amd64_nginx:14.04"
      
      
        
           .
        
        

Uploading context  
      
      
        2.56
      
      
         kB

Uploading context 

Step 
      
      
        0
      
       : FROM tanghuimin0713/ubuntu_amd64:
      
        14.04
      
      

 --->
      
         6cfee0d4349b

Step 
      
      
        1
      
       : RUN apt-
      
        get
      
      
         update

 
      
      ---> Running 
      
        in
      
      
         dedead78ac76

Ign http:
      
      
        //
      
      
        archive.ubuntu.com trusty InRelease
      
      

Hit http:
      
        //
      
      
        archive.ubuntu.com trusty Release.gpg
      
      

Hit http:
      
        //
      
      
        archive.ubuntu.com trusty Release
      
      

Hit http:
      
        //
      
      
        archive.ubuntu.com trusty/main i386 Packages
      
      

Get:
      
        1
      
       http:
      
        //
      
      
        archive.ubuntu.com trusty/main Translation-en [762 kB]
      
      

Fetched 
      
        762
      
       kB 
      
        in
      
       2min 16s (
      
        5571
      
       B/
      
        s)

Reading package lists...

 
      
      --->
      
         3af4720f8ec3

Step 
      
      
        2
      
       : RUN apt-
      
        get
      
       install -
      
        y nginx

 
      
      ---> Running 
      
        in
      
      
         e6a4a63286fe

Reading package lists...

Building dependency tree...

The following extra packages will be installed:

...

...

...

Processing triggers 
      
      
        for
      
       libc-bin (
      
        2.19
      
      -
      
        0ubuntu6) ...

Processing triggers 
      
      
        for
      
       sgml-
      
        base
      
       (
      
        1.26
      
      +
      
        nmu4ubuntu1) ...

 
      
      --->
      
         409a0d5cd91b

Step 
      
      
        3
      
       : RUN echo 
      
        "
      
      
        Hi, I am in your container
      
      
        "
      
       > /usr/share/nginx/html/
      
        index.html

 
      
      ---> Running 
      
        in
      
      
         783d8789509c

 
      
      --->
      
         9a5d96a41a0b

Step 
      
      
        4
      
       : EXPOSE 
      
        80
      
      

 ---> Running 
      
        in
      
      
         a2e24fc2d4b9

 
      
      --->
      
         6cd5691b7c8c

Successfully built 6cd5691b7c8c

Removing intermediate container dedead78ac76

Removing intermediate container e6a4a63286fe

Removing intermediate container 783d8789509c

Removing intermediate container a2e24fc2d4b9

root@ubuntu:
      
      /home/thm/docker/test# 
    

3.? 查看image是否創(chuàng)建成功

      root@ubuntu:/home/thm/docker/
      
        test#
        
           docker images
        
        

REPOSITORY                          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE


        
          tanghuimin0713
        
      
      
        /ubuntu_amd64_nginx   14.04               6cd5691b7c8c        30 seconds ago      259.2
      
      
        
           MB
        
        

scratch                             latest              6e1aa483880d        
      
      
        2
      
       hours ago         
      
        0
      
      
         B

tanghuimin0713
      
      /ubuntu_amd64         
      
        14.04
      
                     6cfee0d4349b        
      
        5
      
       hours ago         
      
        216.8
      
      
         MB

tanghuimin0713
      
      /ubuntu_amd64         latest              6cfee0d4349b        
      
        5
      
       hours ago         
      
        216.8
      
      
         MB

tanghuimin0713
      
      /ubuntu_i386          
      
        14.04
      
                     ee57f53fe012        
      
        6
      
       hours ago         
      
        216.8
      
      
         MB

tanghuimin0713
      
      /ubuntu_i386          latest              ee57f53fe012        
      
        6
      
       hours ago         
      
        216.8
      
      
         MB

ubuntu                              
      
      
        14.04
      
      .
      
        1
      
                   c4ff7513909d        
      
        9
      
       days ago          
      
        225.4
      
      
         MB

ubuntu                              
      
      
        14.04
      
                     c4ff7513909d        
      
        9
      
       days ago          
      
        225.4
      
      
         MB

ubuntu                              latest              c4ff7513909d        
      
      
        9
      
       days ago          
      
        225.4
      
      
         MB

ubuntu                              trusty              c4ff7513909d        
      
      
        9
      
       days ago          
      
        225.4
      
       MB
    

4. run一下新創(chuàng)建的image

      root@ubuntu:/home/thm/docker/test# 
      
        docker run -i -t tanghuimin0713/ubuntu_amd64_nginx:14.04 /bin/
      
      
        
          bash
        
        

root@45494a615738:
      
      /
      
        # 

root@45494a615738:
      
      /
      
        # which nginx


      
      /usr/sbin/nginx
    

nginx命令是存在的,成功。

5. 將新創(chuàng)建的image同步到docker hub

docker push tanghuimin0713/ubuntu_amd64_nginx:14.04

docker開(kāi)發(fā)_在basic image的基礎(chǔ)上創(chuàng)建自定義的image


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

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

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

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

【本文對(duì)您有幫助就好】

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

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 龙井市| 临泽县| 洞口县| 东方市| 化德县| 嘉祥县| 民权县| 阆中市| 台中县| 永平县| 林州市| 福贡县| 苏州市| 磐石市| 肥乡县| 自贡市| 汶上县| 会理县| 留坝县| 宜良县| 无极县| 汨罗市| 张家界市| 宜兰市| 景东| 长兴县| 德保县| 化德县| 红桥区| 夏津县| 日喀则市| 望奎县| 海门市| 巫溪县| 曲松县| 城固县| 汝州市| 东宁县| 长治市| 视频| 黔西县|