centos 7安装docker


1. 安装docker

官方安装文档:
Get Docker CE for CentOS
我参照的:
Centos7安装vim8.0 + YouCompleteMe

4. Swarms

安装docker-machine

1
2
3
base=https://github.com/docker/machine/releases/download/v0.14.0 &&
  curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/usr/local/bin/docker-machine &&
  chmod +x /usr/local/bin/docker-machine

下不下来翻墙拉到本地,再scp到服务器

创建虚拟机

1
docker-machine create --driver virtualbox myvm1

执行到sudo /sbin/vboxconfig这步时,uname -r显示我的内核版本是3.10.0-862.11.6.el7.x86_64,然而安装kernel-devel-3.10.0-862.11.6.el7.x86_64又显示which is newer than kernel-headers-3.10.0-693.el7.x86_64) is already installed
此时查看/usr/src/kernels目录或者sudo rpm -qa kernel查看已安装的内核发现,高版本kernel-3.10.0-862.11.6.el7.x86_64已经安装,只是启动时用的是旧版本。接下来更换启动内核。

 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
32
33
34
35
36
37
38
39
40
41
42
43
# 查看当前系统启动引导项
cat /boot/grub2/grub.cfg |grep menuentry
==输出==
if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
  menuentry_id_option=""
export menuentry_id_option
menuentry 'CentOS Linux (3.10.0-862.11.6.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-862.11.6.el7.x86_64-advanced-efb6682b-abe9-4548-9f7b-18bfefc44f17' {
menuentry 'CentOS Linux (3.10.0-693.el7.x86_64) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.10.0-693.el7.x86_64-advanced-efb6682b-abe9-4548-9f7b-18bfefc44f17' {
menuentry 'CentOS Linux (0-rescue-9eabeb8a12d440c79e7be32fb74f6327) 7 (Core)' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-0-rescue-9eabeb8a12d440c79e7be32fb74f6327-advanced-efb6682b-abe9-4548-9f7b-18bfefc44f17' {

# 备份启动文件
sudo cp /etc/default/grub .

# 将第一个内核作为默认内核
sudo sed -i 's/GRUB_DEFAULT=saved/GRUB_DEFAULT=0/g' /etc/default/grub

# 重新配置内核项
grub2-mkconfig -o /boot/grub2/grub.cfg
==输出==
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-693.21.1.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.21.1.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-123.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-123.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-f892a2a55b8041868ce40ff2a39cc252
Found initrd image: /boot/initramfs-0-rescue-f892a2a55b8041868ce40ff2a39cc252.img
done

# 修改开机时默认使用的内核
grub2-set-default 'CentOS Linux (3.10.0-862.11.6.el7.x86_64) 7 (Core)'

# 查看内核修改结果
grub2-editenv list
==输出==
saved_entry=CentOS Linux (3.10.0-862.11.6.el7.x86_64) 7 (Core)

# 重启系统
reboot

# 查看升级后的Kernel版本
uname -r
3.10.0-862.11.6.el7.x86_64

再运行sudo /sbin/vboxconfig

1
2
3
4
5
6
7
vboxdrv.sh: Stopping VirtualBox services.
vboxdrv.sh: Building VirtualBox kernel modules.
vboxdrv.sh: Starting VirtualBox services.

# 如果Linux是虚拟机,要在BIOS里面打开VT-X/AMD-v
Error with pre-create check: "This computer doesn't have VT-X/AMD-v enabled. Enabling it in the BIOS is mandatory"

参考:CentOS 7 安装Oracle VirtualBox
更新CentOS7上的内核版本
Empty kernel directory but kernel-headers are installed

comments powered by Disqus
Using Hugo & Soda theme
fc4soda ❤ 2018.04.24~