vmware下的centos7系統安裝docker

安裝 docker

系統配置:vmware 12; centos 7。參考 docker 官方文檔來操作安裝:https://docs.docker.com/engine/install/centos/

[root@docker211 ~]# yum install -y yum-utils
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
There are no enabled repos.
 Run "yum repolist all" to see the repos you have.
 To enable Red Hat Subscription Management repositories:
     subscription-manager repos --enable <repo>
 To enable custom repositories:
     yum-config-manager --enable <repo>

虛機如何配置連接上網的步驟在另一篇文章中。

yum源爲空,repolist = 0,查看下系統中yum的配置文件,是否有合適的資源地址。( 注:yum倉庫就是使用yum命令下載軟件的鏡像地址。我們通常使用 yum install 命令來在線安裝 linux系統的軟件, 這種方式可以自動處理依賴性關係,並且一次安裝所有依賴的軟體包,但是經常會遇到從國外鏡像下載速度慢,無法下載的情況。那麼此時我們就需要把我們的yum 源改爲國內的鏡像。)

ls /etc/yum.repos.d

搜索國內yum倉庫,主要有清華和阿里兩個鏡像倉庫配置,但是我兩個都配置過,還是各種的404連接錯誤。然後在查看官方文檔後,使用了第二種安裝方式,rpm包安裝。

Installation methods
You can install Docker Engine in different ways, depending on your needs:

Most users set up Docker’s repositories and install from them, for ease of installation and upgrade tasks. This is the recommended approach. (第一種在線安裝方式 Install using the repository)

Some users download the RPM package and install it manually and manage upgrades completely manually. This is useful in situations such as installing Docker on air-gapped systems with no access to the internet.(第二種RPM包安裝方式,需要先去官網下載相對應的版本文件 Install from a package)

In testing and development environments, some users choose to use automated convenience scripts to install Docker.(第三種未嘗試)

下載地址:https://download.docker.com/linux/centos/ ,路徑:7/x86_64/stable/Packages/ ,這裏我選擇的是穩定版的一個版本,docker-ce-17.03.0.ce-1.el7.centos.x86_64.rpm 。安裝此 rpm 之前還需要下載另一個文件,docker-ce-selinux-17.03.0.ce-1.el7.centos.noarch.rpm ,不然會有報錯,提示錯誤信息如下:error信息展示

安裝 docker engine,路徑換成自己的路徑:

sudo yum install /path/to/xxx-selinux-xxx.rpm
sudo yum install /path/to/docker-ce-xxx.rpm
sudo docker -v 

啓動 docker:

sudo systemctl start docker

通過運行hello-world映像來驗證Docker引擎是否正確安裝:

sudo docker run hello-world

該命令下載一個測試映像並在容器中運行它。當容器運行時,它打印一條信息消息並退出。

終於可以愉快的玩耍 docker 了 !!!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章