Docker中启动Docker问题

尝试在Docker 的Centos容器中继续起个dokcer来测试,但是在容器中运行任何docker命令,如docker ps,都会报错:

Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?

意思Docker没启动,然后尝试去启动:

service docker start

还是

systemctl start docker

都会报错:

System has not been booted with systemd as init system (PID 1). Can’t operate.

然后查看init.d下只有readme,也没有其他启动命令

最后研究一圈发现是Docker内不支持继续起Docker,

其实也很好理解,如果可以一直套娃,岂不是无穷无尽。

You can’t () run Docker inside Docker containers or images. You can’t () start background services inside a Dockerfile. As you say, commands like systemctl and service don’t (*) work inside Docker anywhere. And in any case you can’t use any host-system resources, including the host’s Docker socket, from anywhere in a Dockerfile.

You need to redesign this Dockerfile so that it only installs the software and makes no attempt to start it. Ideally a container would start only a single server, and would run it in the foreground as its CMD; otherwise you might depend on things like supervisord to have multiple servers if you must. If your application heavily relies on being able to start things in Docker, you might find it much easier to install in a virtual machine.

(*) Technically there are ways to do all of these things, but they’re all tricky and complicated and have implications (up to potentially giving your container unrestricted root access over the host, and your container startup actively reconfiguring some low-level host details).

参考:

https://stackoverflow.com/questions/51857634/cannot-connect-to-the-docker-daemon-at-unix-var-run-docker-sock-is-the-docke

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值