主機系統: 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完成,開始發揮你的想象力吧!