Docker Compose运行使用户输入崩溃时出现“断管”

时间:2015-08-23 03:11:16

标签: docker docker-compose

我正在使用Docker来实现Django环境,但是当我运行像docker-compose run web bash之类的命令时,无论我在bash加载之后键入什么都不会显示,然后最终进程因以下错误而死:

Traceback (most recent call last):
  File "/usr/local/Cellar/fig/1.3.3/libexec/bin/docker-compose", line 9, in <module>
    load_entry_point('docker-compose==1.3.3', 'console_scripts', 'docker-compose')()
  File "/usr/local/Cellar/fig/1.3.3/libexec/lib/python2.7/site-packages/compose/cli/main.py", line 32, in main
    command.sys_dispatch()
  File "/usr/local/Cellar/fig/1.3.3/libexec/lib/python2.7/site-packages/compose/cli/docopt_command.py", line 21, in sys_dispatch
    self.dispatch(sys.argv[1:], None)
  File "/usr/local/Cellar/fig/1.3.3/libexec/lib/python2.7/site-packages/compose/cli/command.py", line 34, in dispatch
    super(Command, self).dispatch(*args, **kwargs)
  File "/usr/local/Cellar/fig/1.3.3/libexec/lib/python2.7/site-packages/compose/cli/docopt_command.py", line 24, in dispatch
    self.perform_command(*self.parse(argv, global_options))
  File "/usr/local/Cellar/fig/1.3.3/libexec/lib/python2.7/site-packages/compose/cli/command.py", line 66, in perform_command
    handler(project, command_options)
  File "/usr/local/Cellar/fig/1.3.3/libexec/lib/python2.7/site-packages/compose/cli/main.py", line 358, in run
    dockerpty.start(project.client, container.id, interactive=not options['-T'])
  File "/usr/local/Cellar/fig/1.3.3/libexec/vendor/lib/python2.7/site-packages/dockerpty/__init__.py", line 27, in start
    PseudoTerminal(client, container, interactive=interactive, stdout=stdout, stderr=stderr, stdin=stdin).start()
  File "/usr/local/Cellar/fig/1.3.3/libexec/vendor/lib/python2.7/site-packages/dockerpty/pty.py", line 153, in start
    self._hijack_tty(pumps)
  File "/usr/local/Cellar/fig/1.3.3/libexec/vendor/lib/python2.7/site-packages/dockerpty/pty.py", line 241, in _hijack_tty
    write_stream.do_write()
  File "/usr/local/Cellar/fig/1.3.3/libexec/vendor/lib/python2.7/site-packages/dockerpty/io.py", line 164, in do_write
    raise e
OSError: [Errno 32] Broken pipe

这是我的docker-compose.yml:

web:
  build: .
  ports:
    - "80:80"
  links:
    - postgres
  volumes:
    - .:/code
  env_file: .env
  command: /code/manage.py runserver 0.0.0.0:80

postgres:
  image: postgres:latest

这是我的Dockerfile:

## python, node and bower ##
FROM python:3.4.3
WORKDIR /usr/local
RUN apt-get install curl && \
        curl --silent --location https://deb.nodesource.com/setup_0.12 | bash - && \
        apt-get install -y nodejs && \
        npm install -g bower
ENV PATH /node_modules:$PATH

## code install ##
RUN mkdir /code
WORKDIR /code
ADD ./requirements/ /code/requirements/
RUN pip install -r /code/requirements/docker.txt
ADD ./ /code/

我在OS X 10.10.5上运行Docker 1.8.1,Compose 1.4.0,Machine 0.4.1,Python 2.7.10。我尝试删除所有docker容器并重建我的项目,但是我得到了同样的错误。我也尝试重建我的docker-machine并从头开始一切,但同样的问题又来了。

注意:我可以想到两个可能与此无关的更改:

  1. OS X 10.10.5将我从Python 2.7.6升级到2.7.10。
  2. 我找到了这个Github issue,有人提到在修复“InsecurePlatformWarning”警告后收到此“破管”错误。我在最近几天也应用了一个解决方案来解决这个问题(pip install requests[security]),但在应用这个改变之后,事情就直接起作用了,但是它的组合和python 2.7.10可能有问题吗?
  3. 关于为何崩溃的任何想法?

1 个答案:

答案 0 :(得分:2)

正如michaelperret在docker-compose github issue所描述的那样,他在应用fix for the InsecurePlatformWarning时开始遇到同样的问题。我几天前自己应用了这个修复程序,但看起来“断管”问题在我重新启动系统之前没有出现(OS X将我升级到10.10.5)。

解决方法是卸载一些属于修复程序的软件包:

pip uninstall pyopenssl ndg-httpsclient pyasn1