在Docker容器中构建Pyramid应用程序时出错

时间:2018-06-20 14:22:40

标签: docker python-3.6 pyramid

我正在尝试使用存储库中的代码构建金字塔docker容器。我是Docker的新手,但我已经在dockerfile中尝试过此操作

FROM alpine:3.7

RUN apk add --update\
    python3 \
    py-pip \
    git

RUN pip3 install --upgrade pip
RUN git clone http://my_git_repo test && \
    cd test && \
    pip3 install -e . && \
    initialize_untitled2_db development.ini && \
    pserve development.ini

EXPOSE 6543`

容器中的所有命令都可以运行所有命令,并且一切正常,但是在上一个命令中,他无法启动金字塔应用。

然后我收到以下错误消息:

    Traceback (most recent call last):
  File "/usr/bin/pserve", line 11, in <module>
    sys.exit(main())
  File "/usr/lib/python3.6/site-packages/pyramid/scripts/pserve.py", line 32, in main
    return command.run()
  File "/usr/lib/python3.6/site-packages/pyramid/scripts/pserve.py", line 239, in run
    server(app)
  File "/usr/lib/python3.6/site-packages/paste/deploy/loadwsgi.py", line 189, in server_wrapper
    **context.local_conf)
  File "/usr/lib/python3.6/site-packages/paste/deploy/util.py", line 55, in fix_call
    val = callable(*args, **kw)
  File "/usr/lib/python3.6/site-packages/waitress/__init__.py", line 20, in serve_paste
    serve(app, **kw)
  File "/usr/lib/python3.6/site-packages/waitress/__init__.py", line 11, in serve
    server = _server(app, **kw)
  File "/usr/lib/python3.6/site-packages/waitress/server.py", line 85, in create_server
    sockinfo=sockinfo)
  File "/usr/lib/python3.6/site-packages/waitress/server.py", line 182, in __init__
    self.bind_server_socket()
  File "/usr/lib/python3.6/site-packages/waitress/server.py", line 294, in bind_server_socket
    self.bind(sockaddr)
  File "/usr/lib/python3.6/asyncore.py", line 329, in bind
    return self.socket.bind(addr)
OSError: [Errno 99] Address not available

金字塔应用在容器外部正常运行。就像我对docker所说的我是新手一样,我找不到错误。

应用程序的配置文件在localhost上运行,并且具有端口映射,在docker的localhost上运行也不应该是一个问题。

有人知道是什么导致了此错误吗?

1 个答案:

答案 0 :(得分:0)

配置中的“ localhost”域名似乎存在问题。我将其更改为本地IP地址“ 127.0.0.1”,然后工作正常。