主机系统: CoreOSlinux
iZwz9id7ajv83ikpa2hhn2Z ~ # cat /etc/os-release
NAME="Container Linux by CoreOS"
ID=coreos
VERSION=1590.0.0
VERSION_ID=1590.0.0
BUILD_ID=2017-11-08-0831
PRETTY_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,一下是遇到的额问题的解决。git
首先启动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
docker
特别解释:shell
在CentOS7下若是默认不加init启动命令的话不会启动systemd进程的,报错docker Failed to get D-Bus connection
,参考资料: yhz61010.iteye.com/blog/235259…centos
进入容器后,执行下面命令:bash
yum makecache
yum install -y epel-release
sed -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 htop
yum install kubernetes.x86_64 -y复制代码
经过安装kubernetes工具包会自动安装Docker,app
执行: docker version
:
发现 daemon进程没启动:工具
/❯❯❯ docker version
Client:
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/amd64
Cannot connect to the Docker daemon. Is the docker daemon running on this host?复制代码
而后执行: dockerd
又报如下错oop
INFO[0000] libcontainerd: new containerd process, pid: 624
WARN[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 filesystem INFO[0001] devmapper: Creating filesystem ext4 on device docker-0:46-2619452-base INFO[0001] devmapper: Error while creating filesystem ext4 on device docker-0:46-2619452-base: exec: "mkfs.ext4": exe cutable file not found in $PATH WARN[0001] devmapper: Failed to deactivatePool: Device is Busy FATA[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完成,开始发挥你的想象力吧!