docker-compose在附加后挂起

时间:2018-10-03 03:07:11

标签: python docker ubuntu docker-compose

当我运行docker-compose时,它只是挂起。我的代码的第一行是打印语句,但没有看到任何输出。 docker-compose

version: "3"
services:
  grip-sim-results-parser:
    container_name: grip-sim-results-parser
    build: .
    ports:
      - "5000:5000"

Dockerfile

FROM library/python:3.7-stretch
RUN apt-get update
RUN apt-get install -y vim
ADD . /code
WORKDIR /code
COPY requirements.txt /
RUN pip3 install --trusted-host pypi.org -r /requirements.txt

CMD ["python3", "app.py"]

docker-compose版本

user@ubuntu:~/projects/grip/grip-sim-results-parser$ docker-compose --version
docker-compose version 1.22.0, build f46880fe

Docker版本

user@ubuntu:~/projects/grip/grip-sim-results-parser$ docker --version
Docker version 18.06.1-ce, build e68fc7a

Linux版本

user@ubuntu:~/projects/grip/grip-sim-results-parser$ uname -a
Linux ubuntu 4.13.0-46-generic #51-Ubuntu SMP Tue Jun 12 12:36:29 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

app.py

....
def main():
    print('main')

docker-compose输出

user@ubuntu:~/projects/grip/grip-sim-results-parser$ docker-compose --verbose up --build
compose.config.config.find: Using configuration files: ./docker-compose.yml
docker.utils.config.find_config_file: Trying paths: ['/home/user/.docker/config.json', '/home/user/.dockercfg']
docker.utils.config.find_config_file: Found file at path: /home/user/.docker/config.json
docker.auth.load_config: Found 'auths' section
docker.auth.parse_auth: Found entry (registry='https://index.docker.io/v1/', username='jcald1')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/version HTTP/1.1" 200 543
compose.cli.command.get_client: docker-compose version 1.22.0, build f46880fe
docker-py version: 3.4.1
CPython version: 3.6.6
OpenSSL version: OpenSSL 1.1.0f  25 May 2017
compose.cli.command.get_client: Docker base_url: http+docker://localhost
compose.cli.command.get_client: Docker version: Platform={'Name': ''}, Components=[{'Name': 'Engine', 'Version': '18.06.1-ce', 'Details': {'ApiVersion': '1.38', 'Arch': 'amd64', 'BuildTime': '2018-08-21T17:23:27.000000000+00:00', 'Experimental': 'false', 'GitCommit': 'e68fc7a', 'GoVersion': 'go1.10.3', 'KernelVersion': '4.13.0-46-generic', 'MinAPIVersion': '1.12', 'Os': 'linux'}}], Version=18.06.1-ce, ApiVersion=1.38, MinAPIVersion=1.12, GitCommit=e68fc7a, GoVersion=go1.10.3, Os=linux, Arch=amd64, KernelVersion=4.13.0-46-generic, BuildTime=2018-08-21T17:23:27.000000000+00:00
compose.cli.verbose_proxy.proxy_callable: docker inspect_network <- ('gripsimresultsparser_default')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/networks/gripsimresultsparser_default HTTP/1.1" 404 61
compose.cli.verbose_proxy.proxy_callable: docker info <- ()
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/info HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker info -> {'Architecture': 'x86_64',
 'BridgeNfIp6tables': True,
 'BridgeNfIptables': True,
 'CPUSet': True,
 'CPUShares': True,
 'CgroupDriver': 'cgroupfs',
 'ClusterAdvertise': '',
 'ClusterStore': '',
 'ContainerdCommit': {'Expected': '468a545b9edcd5932818eb9de8e72413e616e86e',
                      'ID': '468a545b9edcd5932818eb9de8e72413e616e86e'},
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_network <- ('grip-sim-results-parser_default')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/networks/grip-sim-results-parser_default HTTP/1.1" 200 590
compose.cli.verbose_proxy.proxy_callable: docker inspect_network -> {'Attachable': True,
 'ConfigFrom': {'Network': ''},
 'ConfigOnly': False,
 'Containers': {},
 'Created': '2018-10-02T22:17:49.401421224-04:00',
 'Driver': 'bridge',
 'EnableIPv6': False,
 'IPAM': {'Config': [{'Gateway': '172.27.0.1', 'Subnet': '172.27.0.0/16'}],
          'Driver': 'default',
          'Options': None},
...
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=False, filters={'label': ['com.docker.compose.project=grip-sim-results-parser', 'com.docker.compose.oneoff=False']})
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/containers/json?limit=-1&all=0&size=0&trunc_cmd=0&filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dgrip-sim-results-parser%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D HTTP/1.1" 200 3
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 0 items)
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=False, filters={'label': ['com.docker.compose.project=gripsimresultsparser', 'com.docker.compose.oneoff=False']})
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/containers/json?limit=-1&all=0&size=0&trunc_cmd=0&filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dgripsimresultsparser%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D HTTP/1.1" 200 3
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 0 items)
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=True, filters={'label': ['com.docker.compose.project=grip-sim-results-parser', 'com.docker.compose.service=grip-sim-results-parser', 'com.docker.compose.oneoff=False']})
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/containers/json?limit=-1&all=1&size=0&trunc_cmd=0&filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dgrip-sim-results-parser%22%2C+%22com.docker.compose.service%3Dgrip-sim-results-parser%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D HTTP/1.1" 200 1133
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 1 items)
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- ('1f8f0b4c36a90c4771e7a2373986dcaed61dbfd140c66b5840bf310edd0c0e68')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/containers/1f8f0b4c36a90c4771e7a2373986dcaed61dbfd140c66b5840bf310edd0c0e68/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {'AppArmorProfile': 'docker-default',
 'Args': ['app.py'],
 'Config': {'ArgsEscaped': True,
            'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': ['python3', 'app.py'],
            'Domainname': '',
            'Entrypoint': None,
            'Env': ['PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
...
compose.service.build: Building grip-sim-results-parser
compose.cli.verbose_proxy.proxy_callable: docker build <- (path='/home/user/grip-sim-results-parser', tag='grip-sim-results-parser_grip-sim-results-parser', rm=True, forcerm=False, pull=False, nocache=False, dockerfile=None, cache_from=None, labels=None, buildargs={}, network_mode=None, target=None, shmsize=None, extra_hosts=None, container_limits={'memory': None}, gzip=False, isolation=None, platform=None)
docker.api.build._set_auth_headers: Looking for auth config
docker.api.build._set_auth_headers: Sending auth config ('https://index.docker.io/v1/')
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.25/build?t=grip-sim-results-parser_grip-sim-results-parser&q=False&nocache=False&rm=True&forcerm=False&pull=False HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker build -> <generator object APIClient._stream_helper at 0x7f5717d10a98>
Step 1/8 : FROM library/python:3.7-stretch
 ---> a9d071760c82
Step 2/8 : RUN apt-get update
 ---> Using cache
 ---> 75cc76eecf8a
Step 3/8 : RUN apt-get install -y vim
 ---> Using cache
 ---> af651ad63dda
Step 4/8 : ADD . /code
 ---> Using cache
 ---> 5ae41ae91671
Step 5/8 : WORKDIR /code
 ---> Using cache
 ---> a709b10facf8
Step 6/8 : COPY requirements.txt /
 ---> Using cache
 ---> 3d1a13239b96
Step 7/8 : RUN pip3 install --trusted-host pypi.org -r /requirements.txt
 ---> Using cache
 ---> 7e6d00d828ae
Step 8/8 : CMD ["python3", "app.py"]
 ---> Using cache
 ---> 1a2bdd386cd1
Successfully built 1a2bdd386cd1
Successfully tagged grip-sim-results-parser_grip-sim-results-parser:latest
compose.cli.verbose_proxy.proxy_callable: docker close <- ()
compose.cli.verbose_proxy.proxy_callable: docker close -> None
compose.cli.verbose_proxy.proxy_callable: docker containers <- (all=True, filters={'label': ['com.docker.compose.project=grip-sim-results-parser', 'com.docker.compose.service=grip-sim-results-parser', 'com.docker.compose.oneoff=False']})
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/containers/json?limit=-1&all=1&size=0&trunc_cmd=0&filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dgrip-sim-results-parser%22%2C+%22com.docker.compose.service%3Dgrip-sim-results-parser%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D HTTP/1.1" 200 1133
compose.cli.verbose_proxy.proxy_callable: docker containers -> (list with 1 items)
compose.cli.verbose_proxy.proxy_callable: docker inspect_image <- ('grip-sim-results-parser_grip-sim-results-parser')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/images/grip-sim-results-parser_grip-sim-results-parser/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_image -> {'Architecture': 'amd64',
 'Author': '',
 'Comment': '',
 'Config': {'ArgsEscaped': True,
            'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': ['python3', 'app.py'],
            'Domainname': '',
            'Entrypoint': None,
...
compose.cli.verbose_proxy.proxy_callable: docker inspect_container <- ('1f8f0b4c36a90c4771e7a2373986dcaed61dbfd140c66b5840bf310edd0c0e68')
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/containers/1f8f0b4c36a90c4771e7a2373986dcaed61dbfd140c66b5840bf310edd0c0e68/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker inspect_container -> {'AppArmorProfile': 'docker-default',
 'Args': ['app.py'],
 'Config': {'ArgsEscaped': True,
            'AttachStderr': False,
            'AttachStdin': False,
            'AttachStdout': False,
            'Cmd': ['python3', 'app.py'],
            'Domainname': '',
            'Entrypoint': None,
            'Env': ['PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
...
compose.parallel.feed_queue: Pending: {<Service: grip-sim-results-parser>}
compose.parallel.feed_queue: Starting producer thread for <Service: grip-sim-results-parser>
Starting grip-sim-results-parser ... 
compose.parallel.feed_queue: Pending: {<Container: grip-sim-results-parser (1f8f0b)>}
compose.parallel.feed_queue: Starting producer thread for <Container: grip-sim-results-parser (1f8f0b)>
compose.cli.verbose_proxy.proxy_callable: docker attach <- ('1f8f0b4c36a90c4771e7a2373986dcaed61dbfd140c66b5840bf310edd0c0e68', stdout=True, stderr=True, stream=True)
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.25/containers/1f8f0b4c36a90c4771e7a2373986dcaed61dbfd140c66b5840bf310edd0c0e68/attach?logs=0&stdout=1&stderr=1&stream=1 HTTP/1.1" 101 0
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/containers/1f8f0b4c36a90c4771e7a2373986dcaed61dbfd140c66b5840bf310edd0c0e68/json HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker attach -> <docker.types.daemon.CancellableStream object at 0x7f5717d32908>
compose.cli.verbose_proxy.proxy_callable: docker start <- ('1f8f0b4c36a90c4771e7a2373986dcaed61dbfd140c66b5840bf310edd0c0e68')
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
compose.parallel.feed_queue: Pending: set()
urllib3.connectionpool._make_request: http://localhost:None "POST /v1.25/containers/1f8f0b4c36a90c4771e7a2373986dcaed61dbfd140c66b5840bf310edd0c0e68/start HTTP/1.1" 204 0
compose.cli.verbose_proxy.proxy_callable: docker start -> None
Starting grip-sim-results-parser ... done
compose.parallel.feed_queue: Pending: set()
compose.parallel.parallel_execute_iter: Finished processing: <Service: grip-sim-results-parser>
compose.parallel.feed_queue: Pending: set()
Attaching to grip-sim-results-parser
compose.cli.verbose_proxy.proxy_callable: docker events <- (filters={'label': ['com.docker.compose.project=grip-sim-results-parser', 'com.docker.compose.oneoff=False']}, decode=True)
urllib3.connectionpool._make_request: http://localhost:None "GET /v1.25/events?filters=%7B%22label%22%3A+%5B%22com.docker.compose.project%3Dgrip-sim-results-parser%22%2C+%22com.docker.compose.oneoff%3DFalse%22%5D%7D HTTP/1.1" 200 None
compose.cli.verbose_proxy.proxy_callable: docker events -> <docker.types.daemon.CancellableStream object at 0x7f5717ce9cc0>

1 个答案:

答案 0 :(得分:1)

要查看python的输出,请尝试向docker-compose.yml添加以下行:

grip-sim-results-parser:
  environment:
    - PYTHONUNBUFFERED=1