流浪者& Docker:容器启动从未离开“停止”状态

时间:2014-07-12 21:54:24

标签: vagrant docker

我跟随vagrant guide to using docker,但是在启动游民时我收到此错误:

Jons-MacBook-Pro:vagrant jonhaven$ vagrant up --provider=docker
Bringing machine 'default' up with 'docker' provider...
==> default: Docker host is required. One will be created if necessary...
    default: Docker host VM is already ready.
==> default: Vagrant has noticed that the synced folder definitions have changed.
==> default: With Docker, these synced folder changes won't take effect until you
==> default: destroy the container and recreate it.
==> default: Starting container...
==> default: Waiting for container to enter "running" state...
The container started either never left the "stopped" state or
very quickly reverted to the "stopped" state. This is usually
because the container didn't execute a command that kept it running,
and usually indicates a misconfiguration.

If you meant for this container to not remain running, please
set the Docker provider configuration "remains_running" to "false":

  config.vm.provider "docker" do |d|
    d.remains_running = false
  end

这是我的Dockerfile(与视频中相同):

Vagrant.configure("2") do |config|
  config.vm.provider "docker" do |d|
    d.image = "paintedfox/postgresql"
  end
end

有没有人见过这个?我在OSX 10.9.4上使用Vagrant工作,否则就不用Docker了。

编辑:

我按照给出的建议并验证我可以通过docker运行我的docker图像。我的工作泊坞命令是这样的:

docker run -p 8888:8888 -d haven / play / opt / activator / activator ui -Dhttp.address = 0.0.0.0

然而,无论我在Vagrant中使用什么组合的create_args或cmd选项,我都无法通过vagrant启动它。要明确的是,问题不是端口,而是docker容器不会继续运行。

1 个答案:

答案 0 :(得分:2)

如果没有保持标准的东西,Docker将会停止。

看起来像paintfox / postgresql CMD是[" / sbin / my_init"] 我假设这是一个非守护进程的命令,意味着保持容器运行,这意味着它会因错误而退出。我会尝试通过手动运行docker来调试:

docker run -i -t paintedfox/postgresql /bin/bash

然后尝试运行命令:

/sbin/my_init

并查看是否以错误退出。如果您在流浪汉中运行docker,您首先必须使用

通过SSH连接到Vagrant
vagrant ssh