在亚马逊Linux上运行Docker容器上的新贵是行不通的

我试图让我的容器在启动时使用暴发户运行。

正如教程所说 – 我创build了/etc/init/nginx_server.conf

description "Nginx docker" author "Me" start on filesystem and started docker stop on runlevel [!2345] respawn script /usr/bin/docker run -d -p 80:80 test_server end script 

运行最新的Amazon Linux( amzn-ami-hvm-2015.03.0.x86_64-gp2

容器没有运行(运行docker ps -a根本不显示)

在Amazon Linux上,Docker守护进程使用init.d脚本启动,而不是Upstart脚本。 在你的Upstart脚本中,你试图在..started docker服务启动的时候..started docker启动(启动..started docker )。 这只会在docker初始化脚本是一个Upstart脚本时才起作用。

你可以添加initctl emit docker-started到docker init.d脚本,然后用这个事件触发你的Upstart服务configuration文件(即start on docker-started

你不能从暴发户做'docker运行',你应该做的是从docker形象创build一个容器,然后在新贵中做'docker开始'​​。 如果你检查/ var / log / messages,你可能会看到类似于:

 init: test_server main process (6570) terminated with status 1 init: test_server respawning too fast, stopped 

要解决它,请尝试运行:

 docker run -d -p 80:80 test_server 

您将获得容器ID作为输出:

 a64db8e1cca5 

然后,把你的暴发户文件:

 description "Nginx docker" start on filesystem and started docker stop on runlevel [!2345] respawn script /usr/bin/docker start -a a64db8e1cca5 end script