无法启动容器

时间:2016-09-27 04:55:17

标签: docker

我是docker的新手,并试图在centos 7.1上使用chef实现docker 下面是我为安装,拉动centos图像和创建容器而编写的基本代码。

所有3个任务都成功执行。由于容器处于停止模式,我尝试通过键入docker start containerid手动启动。当我检查docker ps时,我发现容器未启动。我试了好几次但是无法启动容器。

使用厨师的Docker代码

docker_service 'default' do
  action [:create, :start]
end

docker_image 'centos' do
  action :pull
end

docker_container 'check2' do
  repo 'centos'
  action :create
end

Docker信息:

Containers: 6
 Running: 1
 Paused: 0
 Stopped: 5
Images: 3
Server Version: 1.12.1
Storage Driver: devicemapper
 Pool Name: docker-8:1-523814-pool
 Pool Blocksize: 65.54 kB
 Base Device Size: 10.74 GB
 Backing Filesystem: xfs
 Data file: /dev/loop0
 Metadata file: /dev/loop1
 Data Space Used: 441.3 MB
 Data Space Total: 107.4 GB
 Data Space Available: 28.08 GB
 Metadata Space Used: 1.159 MB
 Metadata Space Total: 2.147 GB
 Metadata Space Available: 2.146 GB
 Thin Pool Minimum Free Space: 10.74 GB
 Udev Sync Supported: true
 Deferred Removal Enabled: false
 Deferred Deletion Enabled: false
 Deferred Deleted Device Count: 0
 Data loop file: /var/lib/docker/devicemapper/devicemapper/data
 WARNING: Usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
 Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata
 Library Version: 1.02.107-RHEL7 (2016-06-09)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: null host bridge overlay
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Security Options: seccomp
Kernel Version: 3.10.0-229.4.2.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 6.807 GiB
ID: R24R:ORHY:XJQW:2HNI:U5TV:UGF7:B7VX:P6Z6:UHSR:YIMR:VGJT:4URU
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: bridge-nf-call-iptables is disabled
WARNING: bridge-nf-call-ip6tables is disabled
Insecure Registries:
 127.0.0.0/8

请你帮帮我

1 个答案:

答案 0 :(得分:2)

默认情况下,centos图片将运行/bin/bash,该图片将立即退出,而不会显示tty(-t)和标准输入(-i)。

尝试在容器中运行

docker_container 'check2' do
  repo 'centos'
  command 'top -b -d 5'
end