debuggingvagrant + docker + flask的最佳实践

我的目标是从Docker容器运行瓶颈web服务器。 在Windows机器上工作,这需要Vagrant来创build一个虚拟机。 运行vagrant –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 

这是stream浪文件

 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中犯了一个错误。 我的问题是双重的:

  1. Dockerfile或Vagrantfile有明显的错误吗?
  2. 有没有办法让stream浪者/docker工生产更具体的错误信息?

我想我正在寻找的答案是使用命令vagrant docker-logs。 我打破了Dockerfile,因为我没有认识到好的行为,因为如果应用程序运行它应该没有真正发生。 docker日志确认烧瓶应用程序正在侦听请求。

Dockerfile或Vagrantfile有明显的错误吗?

你的Dockerfile和Vagrantfiles看起来不错,但我认为你需要修改run.py的权限来执行:

 ... #copy the working directory to the container ADD . / RUN chmod +x run.py CMD python run.py 

那样有用吗?

有没有办法让stream浪者/docker工生产更具体的错误信息?

试着看看stream浪汉的debugging页面 。 我使用的另一种方法是login到容器并尝试手动运行脚本。

 # log onto the vm running docker vagrant ssh # start your container in bash, assuming its already built. docker run -it my/container /bin/bash # now from inside your container try to start your app python run.py 

此外,如果您想在本地查看您的应用程序,则需要将端口转发添加到您的Vagrant文​​件中。