首页 > 系统服务 > 详细

CentOS && Ubuntu 环境下 Docker 的安装配置

时间:2019-08-07 13:28:21      阅读:82      评论:0      收藏:0      [点我收藏+]

CentOS 7 install Docker

Docker 支持的 centos 版本:CentOS 6.5(64-bit)或更高的版本

使用 yum 安装

1)确保 yum 包更新到最新

[root@centos7 ~]# yum update

 

2)Docker 软件包和依赖包已经包含在默认的 CentOS-Extras 软件源里,安装命令如下

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

 

3)安装完成Docker后,默认已经启动了docker服务,如需手动控制docker服务的启停,可执行如下命令

启动docker 
systemctl start docker.service

停止docker 
systemctl stop docker.service

重启docker
systemctl restart docker.service

检查运行状态
systemctl status docker.service

 

4)验证是否安装成功

[root@centos7 ~]# docker version

 

5)测试运行 hello-world

[root@centos7 ~]# docker run hello-world

执行效果:

技术分享图片

 

6)添加开机启动

[root@centos7 ~]# systemctl enable docker

 

Ubuntu install Docker

1)更新 ubuntu 的 apt 源索引

sudo apt-get update

 

2)安装包允许apt通过HTTPS使用仓库

sudo apt-get install     apt-transport-https     ca-certificates     curl     software-properties-common

 

3)添加Docker官方GPG key

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

 

4)设置Docker稳定版仓库

sudo add-apt-repository    "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs)    stable"

 

5)添加仓库后,更新apt源索引

sudo apt-get update

 

6)安装最新版Docker CE(社区版)

sudo apt-get install docker-ce

 

7)检查Docker CE是否安装正确

sudo docker run hello-world

出现如下信息,表示安装成功

技术分享图片

 

8)为了避免每次命令都输入sudo,可以设置用户权限,注意执行后须注销重新登录

sudo usermod -a -G docker $USER

 

9)启动与停止

安装完成Docker后,默认已经启动了docker服务,如需手动控制docker服务的启停,可执行如下命令

# 启动docker
sudo service docker start

# 停止docker
sudo service docker stop

# 重启docker
sudo service docker restart

# 检查运行状态
sudo service docker status

 

 

 

 ending ~

 

CentOS && Ubuntu 环境下 Docker 的安装配置

原文:https://www.cnblogs.com/kaichenkai/p/11314322.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!