2016-11-30 62 views
1

我觀察下面的錯誤,而我下面執行命令錯誤響應:集裝箱f88566c370dd沒有運行

CMD used- docker exec -it f88566c370dd /bin/bash
錯誤遵循 - Error response from daemon: Container f88566c370dd is not running
我什麼doing-試圖從執行廚師食譜虛擬機拉圖像和朗姆酒三個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 

命令

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

預期結果:軟件,如Java,Python或工具,如詹金斯,在tomcat安裝容器

[[email protected] ~]# docker images 
REPOSITORY   TAG     IMAGE ID   CREATED             VIRTUAL SIZE 
centos    latest    97cad5e16cb6  3 weeks ago            196.5 MB 

[[email protected] ~]# 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 
+0

未創建碼頭容器。你能用你正在運行的腳本的輸出更新問題嗎? docker ps -a列出你的容器嗎? – user2599522

+0

@ user2599522-更新了問題。 – Kally

+0

狀態:已退出,你當然無法連接 – YOU

回答

1

爲了保持在容器中,Docker需要命令在前臺繼續運行。

在你的情況下,命令「LS -la /」列表目錄內容和出口,這導致離開所述容器。嘗試使用繼續在前臺運行的命令啓動容器。

1

您的容器只運行一個命令,然後退出

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

認爲這是產生子殼,執行ls -al /,然後退出。

一個黑客,讓他們運行起來會是命令切換到

ls -la /; sleep 10m 

要驗證您的容器已經運行的命令,你可以檢查容器的日誌與

docker logs third 
+0

如何讓他們不斷運行。 ls -la /; 10米後睡10米會使他們失望。 – Kally

+0

以上解決方案也沒有工作。 [root @ sonatadocker〜]#docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES ba6cbedeb3da centos:latest「ls -la /; sleep 10m大約一分鐘前已退出(2)58秒前第三個 – Kally

+0

我有兩個問題:(1)爲什麼你需要一個容器在沒有運行任何命令的情況下啓動並運行?(2)你試過的容器的日誌是什麼 – user2599522

0

通過改變命令「/斌/慶典」我可以看到集裝箱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