CentOS7 docker服務部署

如下命令能夠在root身份下保存爲shell腳本直接bash一次性執行

參考:

https://yeasy.gitbooks.io/docker_practice/install/centos.htmlhtml

https://docs.docker.com/install/linux/docker-ce/centos/linux

http://www.ruanyifeng.com/blog/2018/02/docker-tutorial.htmlgit

#如下全部操做需以root身份執行
#去除本系統中全部可能的無效依賴
yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine
#安裝依賴                  
yum install -y yum-utils \
           device-mapper-persistent-data \
           lvm2
#在中國國內的話設置docker源爲中國科技大學鏡像           
yum-config-manager \
    --add-repo \
    https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
#更新yum緩存
yum makecache fast
#安裝docker-ce(社區版)
yum install docker-ce
#啓動服務
systemctl enable docker
systemctl start docker
#創建docker用戶組(組名可自定義)
groupadd docker-tz
#以root身份將一個普通賬戶加入新的用戶組(切勿將root用戶加入組)
usermod -aG docker-tz tuzhuo
#以root身份運行測試程序
docker run hello-world
# 若能輸出如下信息則本系統docker服務部署成功
# Unable to find image 'hello-world:latest' locally
# latest: Pulling from library/hello-world
# d1725b59e92d: Pull complete
# Digest: sha256:0add3ace90ecb4adbf7777e9aacf18357296e799f81cabc9fde470971e499788
# 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/

 

tz@croplab,hzaudocker

2019/9/28shell

相關文章
相關標籤/搜索