CentOS7 docker服务部署

以下命令可以在root身份下保存为shell脚本直接bash一次性执行

参考:

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

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

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

复制代码
#以下所有操作需以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,hzau

2019/9/28

posted on   tuzhuo  阅读(262)  评论(0编辑  收藏  举报

编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示