一、安装 Linux 虚拟机
1、使用 VMWare、VirtualBox(安装);
2、使用 VirtualBox 导入虚拟机文件 centos7.ova;
3、双击启动 Linux 虚拟机;
4、使用客户端连接 Linux 服务器进行命令操作;
5、设置虚拟机网络:桥接网络=选择与宿主机一》样的网卡-》接入网线
6、设置好网络以后使用命令重启虚拟机的网络
service network restart
7、查看 linux 的 ip 地址
ip addr
8、使用客户端连接 Linux
二、在 Linux 虚拟机上安装 Docker
1、检查内核版本,必须是 3.10 以上
Docker 要求 CentOS 系统的内核版本高于 3.10
uname -r
2、安装 docker
yum install docker
3、输入 y 确认安装
4、启动 docker
[root@localhost ~]# systemctl start docker
[root@localhost ~]# docker ‐v
Docker version 1.12.6, build 3e8e77d/1.12.6
5、开机启动 docker
[root@localhost ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi‐user.target.wants/docker.service to
/usr/lib/systemd/system/docker.service.
6、停止 docker
systemctl stop docker
三、遇到问题
docker 启动报错:
报错信息:
Job for docker.service failed because the control process exited with error code. See "systemctl status docker.service" and "journalctl -xe" for details.
使用命令: systemctl status docker.service 查看 docker.service:
查看启动信息如下状态信息:
解决: 查询各种博客修改配置的方式没有解决问题,重新安装相同版本的Docker也没解决,于是参考几篇博客重新安装新版Docker的解决了此问题,为了后续查阅便利记录本博文。
本机环境是VirtualBox上安装的CentOS7。
安装Docker
1、查看内核版本 <Docker 要求 CentOS 系统的内核版本高于 3.10>
uname -r 本机<内核版本: 3.10.0-327.el7.x86_64>
2、把yum包更新到最新
yum update
3、安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是device mapper驱动依赖的
yum install -y yum-utils device-mapper-persistent-data lvm2
4、设置yum源
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
5、查看仓库中docker版本
yum list docker-ce --showduplicates | sort -r
6、安装docker
yum install docker-ce
7、启动docker,设置开机启动docker
systemctl start docker
systemctl enable docker
systemctl stop docker【补充:这是关闭docker的命令】
8、查看版本
docker version
9、检测是否启动成功,可以使用search命令
docker search mysql
10、查看日志状态
systemctl status docker.service
11、卸载 Docker,对于旧版本没安装成功,卸掉
查看安装的相关信息:
yum list installed | grep docker
删除安装的软件包:
yum -y remove docker.x86_64
yum -y remove docker-client.x86_64
yum -y remove docker-common.x86_64
参考:https://blog.csdn.net/zhangbeizhen18/article/details/85239758