gpt4 book ai didi

Vagrant 和 docker : The container started never left the "stopped" state

转载 作者:行者123 更新时间:2023-12-03 21:44:27 26 4
gpt4 key购买 nike

我正在关注 vagrant guide to using docker但是我在启动 vagrant 时收到这个错误:

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 命令是这样的:

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

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

最佳答案

如果没有任何东西保持标准运行,Docker 将停止。

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

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

然后尝试运行命令:
/sbin/my_init

并查看它是否以错误退出。如果您在 vagrant 中运行 docker,则首先必须使用 SSH 连接到 Vagrant
vagrant ssh

关于 Vagrant 和 docker : The container started never left the "stopped" state,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24717662/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com