大网数据广告活动
服务器运维问答

How can I run a full OS in a Docker container, without specifying a command?

· 52CE 我爱测

I'm following the CoreOS Docker Documentation and it mentions starting containers with commands like: docker run someImageName /bin/somebinary Where someImageName is an image. When /bin/somebinary exits, the image will no longer …

问题原文

原帖链接 · mikemaccana · CC BY-SA 3.0

I'm following the CoreOS Docker Documentation and it mentions starting containers with commands like:

docker run someImageName /bin/somebinary

Where someImageName is an image. When /bin/somebinary exits, the image will no longer be running.

I would simply like to run an image, without specifying any binaries to run. Instead, I simply want to run the services (eg, systemd / sysvinit) that are normally run inside the images OS.

This seems like the most common thing anyone would ever want to do with Docker, but trying to run an image without a command returns:

2014/02/05 14:49:19 Error: create: No command specified

How can I start a Docker container and run a full OS, rather than specifying a command?

已采纳解答

原帖链接 · Fred the Magic Wonder Dog · CC BY-SA 3.0

As documented here, you simply run /sbin/init as the command just like any other unix booting from single user to multi-user mode.

https://stackoverflow.com/questions/19332662/start-full-container-in-docker

Containers can be full blown OS's, they just don't have to be (neither do VMs for that matter, it's just more complicated to configure and manage).

I would say the whole point of Docker is to make application containers easy, so that you only have to configure an app, not the whole OS.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2014-02-05)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。