python – 调试vagrant docker flask的最佳实践

我的目标是从Docker容器运行flask webserver.在
Windows机器上工作需要Vagrant来创建VM.运行vagrant up –provider = docker导致以下投诉:

INFO interface: error: 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

FROM mrmrcoleman/python_webapp

EXPOSE 5000

# Install Python 
RUN apt-get install -y python python-dev python-distribute python-pip

# Add and install Python modules
RUN pip install Flask

#copy the working directory to the container
ADD . /

CMD python run.py

这就是Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.provider "docker" do |d|
    d.build_dir = "." #searches for a local dockerfile

  end
  config.vm.synced_folder ".", "/vagrant", type: "rsync"
  rsync__chown = false
end

因为Vagrantfile和run.py独立工作没有问题,我怀疑我在Dockerfile中犯了一个错误.我的问题是双重的:

> Dockerfile或者是否存在明显错误
Vagrantfile?
>有没有办法让流浪者/Docker生产更多
具体的错误信息?

最佳答案 我认为我正在寻找的答案是使用命令

vagrant docker-logs

我打破了Dockerfile,因为我没有认识到这样的良好行为,因为如果应用程序运行应该没有真正发生的事情. docker-logs确认烧瓶应用正在监听请求.

点赞