来自守护进程的错误响应:容器f88566c370dd未运行

我正在观察下面的错误,而我执行下面的命令

cmd docker exec -it f88566c370dd /bin/bash
观察到Error response from daemon: Container f88566c370dd is not running
我在做什么 – 试图从虚拟机执行厨师食谱拉图像和朗姆酒三个Centos容器。

厨师配方相关

 # # Cookbook Name:: chef-docker # Recipe:: default # # Copyright 2016, SONATA_SOFTWARE # # All rights reserved - Do Not Redistribute # docker_service 'default' do action [:create, :start] end # Pull latest image docker_image 'centos' do tag 'latest' action :pull end # Run container docker_container 'first' do repo 'centos' command 'ls -la /' end docker_container 'second' do repo 'centos' command 'ls -la /' end docker_container 'third' do repo 'centos' command 'ls -la /' end 

在VM中用来执行厨师食谱的命令

 chef-client -r recipe[chef-docker::Default] 

预期结果:在容器中安装诸如java,python之类的软件或诸如Jenkins,tomcat之类的工具

 [root@sonatadocker ~]# docker images REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE centos latest 97cad5e16cb6 3 weeks ago 196.5 MB [root@sonatadocker ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f88566c370dd centos:latest "ls -la /" 18 hours ago Exited (0) 17 hours ago third fdc12e9f65a9 centos:latest "ls -la /" 18 hours ago Exited (0) 17 hours ago second 604f0eba7010 centos:latest "ls -la /" 18 hours ago Exited (0) 17 hours ago first 

为了保持容器,Docker需要命令在前台继续运行。

在你的情况下,命令“ls -la /”列出了目录内容并退出,导致退出容器。 尝试用前景继续运行的命令启动容器。

你的容器只运行一个命令,然后退出

 docker_container 'first' do repo 'centos' command 'ls -la /' end 

认为这是产生一个子shell,执行ls -al /然后退出。

一个黑客保持他们的运行将改变命令

 ls -la /; sleep 10m 

要validation您的容器是否运行了该命令,您可以使用检查容器的日志

 docker logs third 

通过将命令更改为“/ bin / bash”,我可以看到Container处于Up状态

 docker_service 'default' do action [:create, :start] end # Pull latest image docker_image 'centos' do tag 'latest' action :pull end # Run container docker_container 'first' do repo 'centos' command '/bin/bash' tty true action :run end docker_container 'second' do repo 'centos' command '/bin/bash' tty true action :run end