在 centos7.2安裝docker 並設置阿里雲源

現在docker 在原來的基礎上分爲兩個分支版本: Docker CE 和 Docker EE。Docker CE 即社區免費版,Docker EE 即企業版,需付費使用。個人使用Docker CE 好了

刪除系統就的docker組件

[root@host01 ~]# yum remove -y docker \
docker-client docker-client-latest \
docker-common docker-latest \
docker-latest-logrotate \
docker-logrotate docker-selinux \
docker-engine-selinux docker-engine
已加載插件:fastestmirror
參數 docker 沒有匹配
參數 docker-client 沒有匹配
參數 docker-client-latest 沒有匹配
參數 docker-common 沒有匹配
參數 docker-latest 沒有匹配
參數 docker-latest-logrotate 沒有匹配
參數 docker-logrotate 沒有匹配
參數 docker-selinux 沒有匹配
參數 docker-engine-selinux 沒有匹配
參數 docker-engine 沒有匹配
不刪除任何軟件包
[root@host01 ~]# 

安裝一些依賴

[root@host01 ~]# yum install -y yum-utils device-mapper-persistent-data lvm2

添加docker的源

[root@host01 ~]# yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
已加載插件:fastestmirror
adding repo from: https://download.docker.com/linux/centos/docker-ce.repo
grabbing file https://download.docker.com/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo
[root@host01 ~]# 

安裝docker-ce

[root@host01 ~]# yum install -y docker-ce

啓動docker

[root@host01 ~]# systemctl start docker

驗證docker

[root@host01 ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:f9dfddf63636d84ef479d645ab5885156ae030f611a56f3a7ac7f2fdd86d7e4e
Status: Downloaded newer image for hello-world:latest

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/

[root@host01 ~]#

配置阿里雲的源

1、要先註冊一個阿里雲的賬號然後登陸到阿里雲的【容器鏡像服務】頁面,地址:
阿里雲容器鏡像服務
2、在下面截圖處找到加速器地址將加速地址複製下載
3、複製阿里雲上提供的直接命令直接運行即可

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://xxx.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker 
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章