首页 > 云计算 > > Docker安装与启动
Docker官方建议在Ubuntu中安装,因为Docker是基于Ubuntu发布的,而且一般
Docker出现的问题Ubuntu是最先更新或者打补丁的。在很多版本的CentOS中是不支持
更新最新的一些补丁包的。第一种方法:从Ubuntu的仓库直接下载安装:
安装比较简单,这种安装的Docker不是最新版本,不过对于学习够用了,依次执行下面命令进行安装。
$ sudo apt install docker.io
$ sudo systemctl start docker
$ sudo systemctl enable docker
查看是否安装成功
$ docker -v
Docker version 17.12.1-ce, build 7390fc6第二种方法:从Docker仓库下载安装:
这种安装方式首先要保证Ubuntu服务器能够访问Docker仓库地址:
https://download.docker.com/linux/ubuntu,如果能够访问,按照下面的操作步骤进行安装。
1.由于apt官方库里的docker版本可能比较旧,所以先卸载可能存在的旧版本:
sudo apt-get remove docker docker-engine docker-ce docker.io
2、更新apt包索引
sudo apt update
3、安装下载包,可以使apt可以通过HTTPS使用存储库(repository)
sudo apt install apt-transport-https ca-certificates curl software-properties-common
4、添加Docker官方的GPG密钥
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
5.在/etc/apt/sources.list.d/docker.list文件中添加下面内容
deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable
也可以选以下命令方式来设置stable存储库
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
6.再更新一下apt包索引
sudo apt update
7.安装docker-ce
sudo apt install docker-ce
8.查看是否安装成功:
docker –version
------------------
提示:当docker 无法卸载的时候,可以试试以下命令(原因:docker下载的数据源比较对,版本也多,所以很难卸载干净)
1. sudo docker -v
2. sudo apt-get remove docker
3. sudo apt-get remove --auto-remove docker
4. sudo apt-get remove --purge lxc-docker
5. sudo apt-get autoremove --purge ustc是老牌的linux镜像服务提供者了,还在遥远的ubuntu 5.04版本的时候就在用。ustc
的docker镜像加速器速度很快。ustc docker mirror的优势之一就是不需要注册,是真正
的公共服务。
https://lug.ustc.edu.cn/wiki/mirrors/help/docker
编辑该文件:
vi /etc/docker/daemon.json
在该文件中输入如下内容:
{
"registry-mirrors": ["https://docker.mirrors.ustc.edu.cn"]
}
阿里的镜像仓库(国内加速):
{
"registry-mirrors": ["https://72idtxd8.mirror.aliyuncs.com"]
}
systemctl命令是系统服务管理器指令
启动docker:
systemctl start docker
停止docker:
systemctl stop docker
重启docker:
systemctl restart docker
查看docker状态:
systemctl status docker
开机启动:
systemctl enable docker
查看docker概要信息
docker info
查看docker帮助文档
docker ‐‐help获取更多IT学习资料:(java、架构师、python、智能机器人、数据分析、大数据等)

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/31537575/viewspace-3147806/ ,如需转载,请注明出处,否则将追究法律责任。