“docker-compose up”无法构建,命令“/bin/sh -c pipenv install”返回非零代码:1

问题描述

从 github 克隆一个项目,在 README 文件中它有做的说明

docker-compose up --build
npm run dev

所以我在终端中输入了 docker-compose up --build。它似乎一直工作到

Installing dependencies from Pipfile.lock (68781d)...

然后我不得不等待几分钟并收到以下错误

Installing dependencies from Pipfile.lock (68781d)...
An error occurred while installing tensorflow==2.4.1 --hash=sha256:36d5acd60aac48e34bd545d0ce1fb8b3fceebff6b8782436defd0f71c12203bd --hash=sha256:55368ba0bedb513ba0e36a2543a588b5276e9b2ca99fa3232a9a176601a7bab5 --hash=sha256:e1f2799cc86861680d8515167f103e2207a8cab92a4afe5471e4839330591f08 --hash=sha256:22723b8e1fa83b34f56c349b16a57aaff913b404451fcf70981f2b1d6e0c64fc --hash=sha256:efa9daa4b3701a4e439b24b74c1e4b66844aee8ae5263fb3cc12281ac9cc9f67 --hash=sha256:2357112319303da1b5459a621fd0503c2b2cd97b6c33c4903abd46b3c3e380e2 --hash=sha256:4a04081647b89a8fb602895b29ffc559e3c20aac8bde1d4c5ecd2a65adce5d35 --hash=sha256:0e427b1350be6dbe572f971947c5596fdbb152081f227808d8becd894bf40282 --hash=sha256:eedcf578afde5e6e69c75d796bed41093451cd1ab54afb438760e40fb74a09de! Will try again.
An error occurred while installing torch==1.7.1; python_full_version >= '3.6.2' --hash=sha256:f0aaf657145533824b15f2fd8fde8f8c67fe6c6281088ef588091f03fad90243 --hash=sha256:5d76c255a41484c1d41a9ff570b9c9f36cb85df9428aa15a58ae16ac7cfc2ea6 --hash=sha256:a3793dcceb12b1e2281290cca1277c5ce86ddfd5bf044f654285a4d69057aea7 --hash=sha256:e000b94be3aa58ad7f61e7d07cf379ea9366cf6c6874e68bd58ad0bdc537b3a7 --hash=sha256:af464a6f4314a875035e0c4c2b07517599704b214634f4ed3ad2e748c5ef291f --hash=sha256:de84b4166e3f7335eb868b51d3bbd909ec33828af27290b4171bce832a55be3c --hash=sha256:38d67f4fb189a92a977b2c0a38e4f6dd413e0bf55aa6d40004696df7e40a71ff --hash=sha256:d241c3f1c4d563e4ba86f84769c23e12606db167ee6f674eedff6d02901462e3 --hash=sha256:dd2fc6880c95e836960d86efbbc7f63d3287f2e1893c51d31f96dbfe02f0d73e --hash=sha256:6652a767a0572ae0feb74ad128758e507afd3b8396b6e7f147e438ba8d4c6f63 --hash=sha256:422e64e98d0e100c360993819d0307e5d56e9517b26135808ad68984d577d75a --hash=sha256:2e49cac969976be63117004ee00d0a3e3dd4ea662ad77383f671b8992825de1a! Will try again.
An error occurred while installing torchvision==0.8.2 --hash=sha256:24db8f4c3d812a032273f68563ad5dbd724f5bfbed523d0c6dce8cede26bb153 --hash=sha256:afb76a66b9b0693f758a881a2bf333ed97e3c0c3f15a413c4f49d8dd8bd21307 --hash=sha256:976750a49db2e23dc5a1ed0b5c31f7af51ed2702eee410ee09ef985c3a3e48cf --hash=sha256:1bd58acc3366ec02266aae56a7a752d43ef07de4a6ba420c4f907d0c9168bb8c --hash=sha256:cd8817e9197fc60ebae37162a445db90bbf35591314a5767ad3d1490b5d65b0f --hash=sha256:86fae370d222f76ad57c57c3bee03f78b8db727743bfb4c1559a3d395159cea8 --hash=sha256:b068f6bcbe91bdd34dda0a39e8a26392add45a3be82543f6dd523b76484fb56f --hash=sha256:951239b5fcb911dbf78c1385d677f5f48c7a1b12859e3d3ec287562821b17cf2! Will try again.
An error occurred while installing tqdm==4.56.0; python_version >= '2.7' and python_version not in '3.0,3.1,3.2,3.3' --hash=sha256:fe3d08dd00a526850568d542ff9de9bbc2a09a791da3c334f3213d8d0bbbca65 --hash=sha256:4621f6823bab46a9cc33d48105753ccbea671b68bab2c50a9f0be23d4065cb5a! Will try again.
An error occurred while installing transformers==4.2.2 --hash=sha256:d0999ababcc3e416a51c42823b56f5116acc5c0913e44e829e83d0db2d475021 --hash=sha256:e151ee7a56e7649de567ad6f4d6a83245c564ca93a886ef0e025f058895cf9cc! Will try again.
An error occurred while installing twitter==1.18.0 --hash=sha256:acdc85e5beea752967bb64c63bde8b915c49a31a01db1b2fecccf9f2c1d5c44d --hash=sha256:52545fd3b70d3d3807d3ce62d1a256727856d784d1630d64dedcc643aaf0b908! Will try again.
An error occurred while installing typing-extensions==3.7.4.3 --hash=sha256:7cb407020f00f7bfc3cb3e7881628838e69d8f3fcab2f64742a5e76b2f841918 --hash=sha256:99d4073b617d30288f569d3f13d2bd7548c3a7e4c8de87db09a9d29bb3a4a60c --hash=sha256:dafc7639cde7f1b6e1acc0f457842a83e722ccca8eef5270af2d74792619a89f! Will try again.
An error occurred while installing unidic-lite==1.0.7 --hash=sha256:260798392fddc8746d7d5596dc9f9a4250a10f41961771cf709ec2dc7db8260a! Will try again.
An error occurred while installing uritemplate==3.0.1; python_version >= '2.7' and python_version not in '3.0,3.3' --hash=sha256:07620c3f3f8eed1f12600845892b0e036a2420acf513c53f7de0abd911a5894f --hash=sha256:5af8ad10cec94f215e3f48112de2022e1d5a37ed427fbd88652fa908f2ab7cae! Will try again.
An error occurred while installing urllib3==1.26.2; python_version >= '2.7' and python_version not in '3.0,3.3,3.4' and python_version < '4' --hash=sha256:d8ff90d979214d7b4f8ce956e80f4028fc6860e4431f731ea4a8c08f23f99473 --hash=sha256:19188f96923873c92ccb987120ec4acaa12f0461fa9ce5d3d0772bc965a39e08! Will try again.
An error occurred while installing werkzeug==1.0.1; python_version >= '2.7' and python_version not in '3.0,3.4' --hash=sha256:6c80b1e5ad3665290ea39320b91e1be1e0d5f60652b964a3070216de83d2e47c --hash=sha256:2de2a5db0baeae7b2d2664949077c2ac63fbd16d98da0ff71837f7d1dea3fd43! Will try again.
An error occurred while installing wheel==0.36.2; python_version >= '3' --hash=sha256:78b5b185f0e5763c26ca1e324373aadd49182ca90e825f7853f4b2509215dc0e --hash=sha256:e11eefd162658ea59a60a0f6c7d493a7190ea4b9a85e335b33489d9f17e0245e! Will try again.
Installing initially Failed dependencies...
An error occurred while installing wrapt==1.12.1 --hash=sha256:b62ffa81fb85f4332a4f609cab4ac40709470da05643a082ec1eb88e6d9b97d7! Will try again.
[InstallError]:   File "/usr/local/lib/python3.8/site-packages/pipenv/cli/command.py",line 233,in install
[InstallError]:       retcode = do_install(
[InstallError]:   File "/usr/local/lib/python3.8/site-packages/pipenv/core.py",line 2052,in do_install
[InstallError]:       do_init(
[InstallError]:   File "/usr/local/lib/python3.8/site-packages/pipenv/core.py",line 1304,in do_init
[InstallError]:       do_install_dependencies(
[InstallError]:   File "/usr/local/lib/python3.8/site-packages/pipenv/core.py",line 899,in do_install_dependencies
[InstallError]:       batch_install(
[InstallError]:   File "/usr/local/lib/python3.8/site-packages/pipenv/core.py",line 796,in batch_install
[InstallError]:       _cleanup_procs(procs,Failed_deps_queue,retry=retry)
[InstallError]:   File "/usr/local/lib/python3.8/site-packages/pipenv/core.py",line 703,in _cleanup_procs
[InstallError]:       raise exceptions.InstallError(c.dep.name,extra=err_lines)
[pipenv.exceptions.InstallError]: WARNING: retrying (Retry(total=4,connect=None,read=None,redirect=None,status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fd8389ffc70>: Failed to establish a new connection: [Errno -2] Name or service not kNown')': /simple/tensorflow/
[pipenv.exceptions.InstallError]: WARNING: retrying (Retry(total=3,status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fd8389ffee0>: Failed to establish a new connection: [Errno -2] Name or service not kNown')': /simple/tensorflow/
[pipenv.exceptions.InstallError]: WARNING: retrying (Retry(total=2,status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fd8383f5070>: Failed to establish a new connection: [Errno -2] Name or service not kNown')': /simple/tensorflow/
[pipenv.exceptions.InstallError]: WARNING: retrying (Retry(total=1,status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fd8383f51f0>: Failed to establish a new connection: [Errno -2] Name or service not kNown')': /simple/tensorflow/
[pipenv.exceptions.InstallError]: WARNING: retrying (Retry(total=0,status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7fd8383f53d0>: Failed to establish a new connection: [Errno -2] Name or service not kNown')': /simple/tensorflow/
[pipenv.exceptions.InstallError]: ERROR: Could not find a version that satisfies the requirement tensorflow==2.4.1
[pipenv.exceptions.InstallError]: ERROR: No matching distribution found for tensorflow==2.4.1
ERROR: Couldn't install package: tensorflow
 Package installation Failed...
ERROR: Service 'youtuberboard' Failed to build : The command '/bin/sh -c pipenv install --system' returned a non-zero code: 1

为什么会出现这些错误,我该如何解决

如果我执行 docker images,我可以检查图像是否已制作,但是当我检查 docker ps -a 时似乎没有制作容器。 容器为什么不造?

编辑: 所以我认为使用 pipfile.lock 是问题,所以在 Dockerfile 中我更改了

RUN pipenv install --system

RUN pipenv install --system --verbose --skip-lock

添加--skip-lock

这不是答案,我仍然遇到类似的错误

.
. (deleting some lines)
.
Skipping link: none of the wheel's tags match: cp39-cp39-win_amd64: https://files.pythonhosted.org/packages/d6/c1/70f2fd464a895844a9bf4cf1d93b09eb6cd5edf8274d19a7fed2ed6c4cc3/torch-1.7.1-cp39-cp39-win_amd64.whl#sha256=6652a767a0572ae0feb74ad128758e507afd3b8396b6e7f147e438ba8d4c6f63 (from https://pypi.org/simple/torch/) (requires-python:>=3.6.2)
  Skipping link: none of the wheel's tags match: cp39-none-macosx_10_9_x86_64: https://files.pythonhosted.org/packages/79/c8/7f7843dcbaf2263918d257e8022770be577a3d7587dd0ddf8171947eabb4/torch-1.7.1-cp39-none-macosx_10_9_x86_64.whl#sha256=38d67f4fb189a92a977b2c0a38e4f6dd413e0bf55aa6d40004696df7e40a71ff (from https://pypi.org/simple/torch/) (requires-python:>=3.6.2)
Given no hashes to check 1 links for project 'torch': discarding no candidates
Collecting torch==1.7.1
  Created temporary directory: /tmp/pip-unpack-uv81hb8h
  Looking up "https://files.pythonhosted.org/packages/1d/a9/f349273a0327fdf20a73188c9c3aa7dbce68f86fad422eadd366fd2ed7a0/torch-1.7.1-cp38-cp38-manylinux1_x86_64.whl" in the cache
  No cache entry available
  Starting new HTTPS connection (1): files.pythonhosted.org:443
  https://files.pythonhosted.org:443 "GET /packages/1d/a9/f349273a0327fdf20a73188c9c3aa7dbce68f86fad422eadd366fd2ed7a0/torch-1.7.1-cp38-cp38-manylinux1_x86_64.whl HTTP/1.1" 200 776818711
  Downloading torch-1.7.1-cp38-cp38-manylinux1_x86_64.whl (776.8 MB)
  Ignoring unkNown cache-control directive: immutable
  Updating cache with response from "https://files.pythonhosted.org/packages/1d/a9/f349273a0327fdf20a73188c9c3aa7dbce68f86fad422eadd366fd2ed7a0/torch-1.7.1-cp38-cp38-manylinux1_x86_64.whl"
  Caching due to etag
    sys.exit(cli())
  File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py",line 829,in __call__
    return self.main(*args,**kwargs)
  File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py",line 782,in main
    rv = self.invoke(ctx)
  File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py",line 1259,in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py",line 1066,in invoke
    return ctx.invoke(self.callback,**ctx.params)
  File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/core.py",line 610,in invoke
    return callback(*args,**kwargs)
  File "/usr/local/lib/python3.8/site-packages/pipenv/vendor/click/decorators.py",line 73,in new_func
    return ctx.invoke(f,obj,*args,line 21,in new_func
    return f(get_current_context(),**kwargs)
  File "/usr/local/lib/python3.8/site-packages/pipenv/cli/command.py",in install
    retcode = do_install(
  File "/usr/local/lib/python3.8/site-packages/pipenv/core.py",in do_install
    do_init(
  File "/usr/local/lib/python3.8/site-packages/pipenv/core.py",in do_init
    do_install_dependencies(
  File "/usr/local/lib/python3.8/site-packages/pipenv/core.py",line 903,in do_install_dependencies
    _cleanup_procs(procs,retry=False)
  File "/usr/local/lib/python3.8/site-packages/pipenv/core.py",in _cleanup_procs
    raise exceptions.InstallError(c.dep.name,extra=err_lines)
pipenv.exceptions.InstallError: ERROR: Couldn't install package: facenet-pytorch
 Package installation Failed...
ERROR: Service 'youtuberboard' Failed to build : The command '/bin/sh -c pipenv install --system --verbose --skip-lock' returned a non-zero code: 1

解决方法

我需要增大 docker 内存大小。更改了泊坞窗设置。