Mac Docker运行Python记录2
昨天下午放假了,就没有继续研究这个,今天继续:
根据报错内容,意思是:我的base image用的是debian,但是它只支持Ubantu
所以,我们修改我们的Dockerfile:
1 FROM brunneis/python:3.8.3-ubuntu-20.04 2 3 WORKDIR ./project 4 5 ADD . . 6 7 RUN pip install -r requirements.txt 8 9 CMD ["python", "./src/tian_mao.py"]
然后,我们重新打包一个新的镜像:
1 (base) kaka@KakadeMacBook-Pro project % docker build -t brunneis/python:3.8.3 . 2 [+] Building 26.9s (3/3) FINISHED 3 => [internal] load build definition from Dockerfile 0.0s 4 => => transferring dockerfile: 185B 0.0s 5 => [internal] load .dockerignore 0.0s 6 => => transferring context: 2B 0.0s 7 => ERROR [internal] load metadata for docker.io/brunneis/python:3.8.3-ubuntu-20.04 26.8s 8 ------ 9 > [internal] load metadata for docker.io/brunneis/python:3.8.3-ubuntu-20.04: 10 ------ 11 failed to solve with frontend dockerfile.v0: failed to create LLB definition: unexpected status code [manifests 3.8.3-ubuntu-20.04]: 403 Forbidden 12 (base) kaka@KakadeMacBook-Pro project %
又报错,然后上网查询,好像是镜像问题,随即查阅一番资料,得到结论,原来是Docker Desktop的设置问题,需要将setting->Docker Engine
的json
配置文件中的。
1 "features": { 2 "buildkit": true 3 },
修改一下这个设置:
然后我们再次测试,又报错:
1 (base) kaka@KakadeMacBook-Pro project % docker build -t brunneis/python:3.8.3 . 2 [+] Building 23.8s (3/3) FINISHED 3 => [internal] load build definition from Dockerfile 0.0s 4 => => transferring dockerfile: 37B 0.0s 5 => [internal] load .dockerignore 0.0s 6 => => transferring context: 2B 0.0s 7 => ERROR [internal] load metadata for docker.io/brunneis/python:3.8.3-ubuntu-20.04 23.7s 8 ------ 9 > [internal] load metadata for docker.io/brunneis/python:3.8.3-ubuntu-20.04: 10 ------ 11 failed to solve with frontend dockerfile.v0: failed to create LLB definition: unexpected status code [manifests 3.8.3-ubuntu-20.04]: 403 Forbidden 12 (base) kaka@KakadeMacBook-Pro project %
还是和上面的一样,这也没有解决问题啊,但是我好像是docker设置完没有应用,我保存了一下设置,然后重新启动了docker,在进行:
1 (base) kaka@KakadeMacBook-Pro project % docker build -t brunneis/python:3.8.3 . 2 Sending build context to Docker daemon 1.089GB 3 Step 1/5 : FROM brunneis/python:3.8.3-ubuntu-20.04 4 3.8.3-ubuntu-20.04: Pulling from brunneis/python 5 d51af753c3d3: Pull complete 6 fc878cd0a91c: Pull complete 7 6154df8ff988: Pull complete 8 fee5db0ff82f: Pull complete 9 05021775f466: Pull complete 10 Digest: sha256:76d5b1e43e101ee88f4bc6edd9d749f920884c02295c5249373dac3dd5a592ca 11 Status: Downloaded newer image for brunneis/python:3.8.3-ubuntu-20.04 12 ---> 8b8f1f847b96 13 Step 2/5 : WORKDIR ./project 14 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 15 ---> Running in f68bfb0fa8ef 16 Removing intermediate container f68bfb0fa8ef 17 ---> d5465f209560 18 Step 3/5 : ADD . . 19 ---> 6908013f64a5 20 Step 4/5 : RUN pip install -r requirements.txt 21 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 22 ---> Running in 2f012e55ea71 23 Collecting playwright==1.31.1 24 Downloading playwright-1.31.1-py3-none-manylinux1_x86_64.whl (35.0 MB) 25 Collecting greenlet==2.0.1 26 Downloading greenlet-2.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (544 kB) 27 Collecting typing-extensions; python_version <= "3.8" 28 Downloading typing_extensions-4.5.0-py3-none-any.whl (27 kB) 29 Collecting pyee==9.0.4 30 Downloading pyee-9.0.4-py2.py3-none-any.whl (14 kB) 31 Installing collected packages: greenlet, typing-extensions, pyee, playwright 32 Successfully installed greenlet-2.0.1 playwright-1.31.1 pyee-9.0.4 typing-extensions-4.5.0 33 WARNING: You are using pip version 20.1.1; however, version 23.0.1 is available. 34 You should consider upgrading via the '/usr/local/bin/python3.8 -m pip install --upgrade pip' command. 35 Removing intermediate container 2f012e55ea71 36 ---> 8481621b77d9 37 Step 5/5 : CMD ["python", "./src/tian_mao.py"] 38 ---> [Warning] The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 39 ---> Running in a92a1720f286 40 Removing intermediate container a92a1720f286 41 ---> 62997548a521 42 Successfully built 62997548a521 43 Successfully tagged brunneis/python:3.8.3 44 45 Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them 46 (base) kaka@KakadeMacBook-Pro project %
我也不知道这算是行还是不行,但是我看docker images 是多了一个新的:
先不管了,先试一下能不能运行:
1 (base) kaka@KakadeMacBook-Pro project % docker run -t -i brunneis/python:3.8.3 /bin/bash 2 WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 3 File "/bin/bash", line 1 4 SyntaxError: Non-UTF-8 code starting with '\x82' in file /bin/bash on line 2, but no encoding declared; see http://python.org/dev/peps/pep-0263/ for details 5 (base) kaka@KakadeMacBook-Pro project % docker run -t -i brunneis/python:3.8.3 6 WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 7 python: can't open file 'python': [Errno 2] No such file or directory 8 (base) kaka@KakadeMacBook-Pro project %
又不行,我好难过,呜呜呜🥹