Centos7 Docker環境安裝

目標

  • 從哪下載
  • 如何安裝
  • 驗證安裝成功

從哪下載

官網:https://docs.docker.com/
本文以Centos7爲準,如果之前有舊版本可以參照官網步驟卸載掉
在這裏插入圖片描述
在這裏插入圖片描述

如何安裝

在安裝前需要關閉防火牆和SELINUX=disabled


[root@k8s-master tomcat]# systemctl stop firewalld
[root@k8s-master tomcat]# systemctl disable firewalld
[root@k8s-master tomcat]# vim /etc/selinux/config

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     disabled - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of disabled.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted


以上配置後執行下面一套命令

# 安裝依賴包
yum install -y yum-utils device-mapper-persistent-data lvm2

# 添加Docker軟件包源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
有些機器可能連接不上地址備用(yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo)

# 安裝Docker CE
yum install -y docker-ce

# 啓動Docker服務並設置開機啓動
systemctl start docker
systemctl enable docker

驗證安裝成功

命令:docker run hello-world 出現以下信息代表安裝成功



[root@k8s-master tomcat]# docker run hello-world
Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
0e03bdcc26d7: Pull complete 
Digest: sha256:6a65f928fb91fcfbc963f7aa6d57c8eeb426ad9a20c7ee045538ef34847f44f1
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@k8s-master tomcat]# 

ok 正式開啓Docker之旅!

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