Docker簡明教程(以安裝wget程式為例)

來源:互聯網
上載者:User

標籤:style   blog   http   color   os   io   art   div   

本文計劃:
  • 一.安裝Docker(Centos)
  • 二.註冊Docker官網帳號
  • 三.下載基礎centos鏡像,安裝需要的軟體和環境後,push到自己的repository

 

一.安裝Docker(Centos)

在https://fedoraproject.org/wiki/EPEL#How_can_I_use_these_extra_packages.3F 中選擇自己的epel源.

接著,安裝docker-io:

$ sudo yum install docker-io

啟動Docker daemon:

$ sudo service docker start

將Docker設定成開機啟動:

$ sudo chkconfig docker on

下載最新的基礎centos:

$ sudo docker pull centos:latest

測試centos是否可以運行成功:

$ sudo docker images centos
二.註冊Docker官網帳號

註冊自己的Docker倉庫帳號,作用相當於開闢一個image倉庫,等同於GitHub:

https://hub.docker.com/account/signup/

三.下載別人的image,作出修改後,push到自己的repository

下面舉個例子,我在image:centos中安裝wget後,提交到自己的repository:

進入操作介面

[[email protected]113058 ~]# sudo docker run -i -t centos /bin/bashbash-4.2#

安裝wget,安裝結束後退出:

bash-4.2# yum install wgetbash-4.2#exit

查看自己的修改記錄:

[[email protected]113058 ~]# docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES5f962b864221 centos:latest /bin/bash 2 minutes ago Exited (0) 42 seconds ago goofy_mcclintock 36f07f440c17 centos:latest /bin/bash 38 minutes ago Exited (0) 35 minutes ago boring_kowalevski 38e000fbee87 centos:latest /bin/bash 41 minutes ago Exited (127) 40 minutes ago sleepy_yonath

可以看到,最近提交的是5f962b864221,這個即是我們安裝了wget的image,將它push到自己的repository,有三個步驟:

[[email protected]113058 ~]# docker commit 5f962b864221 alexknight/centos-wget

其中,alexknight是自己在倉庫裡開闢的空間名,接下來是登入自己的帳號

[[email protected]113058 ~]# docker login -u "第二步註冊的名字" -p "passwd" -e "郵箱地址"

登入成功後,push自己的提交

[[email protected]113058 ~]# docker push alexknight/centos-wget

當在介面看到centos-wget時,操作成功。

把自己提交的centos-wget下載:

[[email protected]113058 ~]# docker pull alexknight/centos-wgetPulling repository alexknight/centos-wgetaa194d98cc9e: Download complete 511136ea3c5a: Download complete 34e94e67e63a: Download complete 1a7dc42f78ba: Download complete

再次進入到自己的centos-wget這個版本進行持續提交時:

[[email protected]113058 ~]#sudo docker run -i -t alexknight/centos-wget /bin/bash

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.