主机系统: CoreOS
iZwz9id7ajv83ikpa2hhn2Z ~ # cat /etc/os-releaseNAME="Container Linux by CoreOS"ID=coreosVERSION=1590.0.0VERSION_ID=1590.0.0BUILD_ID=2017-11-08-0831PRETTY_NAME="Container Linux by CoreOS 1590.0.0 (Ladybug)"ANSI_COLOR="38;5;75"HOME_URL="https://coreos.com/"BUG_REPORT_URL="https://issues.coreos.com"COREOS_BOARD="amd64-usr"复制代码
由于CoreOS没有包管理工具且是只读文件系统,不能方便的安装流行的Linux世界的软件,所以打算在CoreOS上在运行个CentOS7,然后在容器内部再部署一套Docker,一下是遇到的额问题的解决。
首先启动CentOS容器:
docker run -d --name=ctj --restart=always -e "container=docker" --privileged=true -p 2222:22 -p 2121:21 -v /sys/fs/cgroup:/sys/fs/cgroup -v /var/run/docker.sock:/var/run/docker.sock -v /root:/root -v /home:/home centos /usr/sbin/init
特别解释:
在CentOS7下如果默认不加init启动命令的话不会启动systemd进程的,报错docker Failed to get D-Bus connection
,参考资料:
进入容器后,执行下面命令:
yum makecache yum install -y epel-releasesed -e 's!^mirrorlist=!#mirrorlist=!g' -e 's!^#baseurl=!baseurl=!g' -e 's!//download\.fedoraproject\.org/pub!//mirrors.ustc.edu.cn!g' -e 's!http://mirrors\.ustc!https://mirrors.ustc!g' -i /etc/yum.repos.d/epel.repo /etc/yum.repos.d/epel-testing.repo yum makecache yum install htopyum install kubernetes.x86_64 -y复制代码
通过安装kubernetes工具包会自动安装Docker,
执行: docker version
:
/❯❯❯ docker versionClient: Version: 1.12.6 API version: 1.24 Package version: docker-1.12.6-61.git85d7426.el7.centos.x86_64 Go version: go1.8.3 Git commit: 85d7426/1.12.6 Built: Tue Oct 24 15:40:21 2017 OS/Arch: linux/amd64Cannot connect to the Docker daemon. Is the docker daemon running on this host?复制代码
然后执行: dockerd
又报以下错
INFO[0000] libcontainerd: new containerd process, pid: 624WARN[0001] devmapper: Usage of loopback devices is strongly discouraged for production use. Please use `--storage-opt dm.thinpooldev` or use `man docker` to refer to dm.thinpooldev section.WARN[0001] devmapper: XFS is not supported in your system. Either the kernel doesn't support it or mkfs.xfs is not in your PATH. Defaulting to ext4 filesystemINFO[0001] devmapper: Creating filesystem ext4 on device docker-0:46-2619452-baseINFO[0001] devmapper: Error while creating filesystem ext4 on device docker-0:46-2619452-base: exec: "mkfs.ext4": exe cutable file not found in $PATHWARN[0001] devmapper: Failed to deactivatePool: Device is BusyFATA[0001] Error starting daemon: error initializing graphdriver: exec: "mkfs.ext4": executable file not found in $PA TH复制代码
这里有两个问题,一个是 没有安装 iptables,另一个问题是 没有 mkfs.ext4 命令,
执行yum install -y e4fsprogs iptables.x86_64
然后加载ext4模块, modprobe ext4
再执行 dockerd
发现能启动了 虽然有error但不影响使用,然后Ctrl^c 退出,使用 systemctl enable docker
允许自启动,systemctl start docker
启动Docker,
来个命令测试下:
现在 Docker内再启动Docker完成,开始发挥你的想象力吧!