记录错误:
1 (base) kaka@KakadeMacBook-Pro project % docker images 2 REPOSITORY TAG IMAGE ID CREATED SIZE 3 python/playwright_tianmao 3.10 24afb40d4b24 13 minutes ago 1.01GB 4 clickhouse/clickhouse-server <none> 854810a3ea35 2 months ago 705MB 5 redis alpine 7bf9ac7d3b84 3 months ago 28.1MB 6 mysql/mysql-server 8.0 55af6abb77a6 4 months ago 527MB 7 fp2_0-8.1/app latest 53b297f8c7a6 7 months ago 1.61GB 8 clickhouse/clickhouse-server latest d846490c0466 14 months ago 794MB 9 prom/prometheus latest ccf2871d6122 14 months ago 198MB 10 grafana/grafana-enterprise latest 05048bc21afe 15 months ago 290MB 11 prom/alertmanager latest 44a71f29f42b 18 months ago 55.3MB 12 (base) kaka@KakadeMacBook-Pro project % docker run -t -i python/playwright_tianmao:3.10 /bin/bash 13 root@a45ac5bafe65:/project# ls 14 Dockerfile requirements.txt src 15 root@a45ac5bafe65:/project# cd src 16 root@a45ac5bafe65:/project/src# ls 17 test0303.py tian_mao.py 18 root@a45ac5bafe65:/project/src# python tian_mao.py 19 Traceback (most recent call last): 20 File "/project/src/tian_mao.py", line 100, in <module> 21 run (playwright) 22 File "/project/src/tian_mao.py", line 22, in run 23 context = playwright.chromium.launch_persistent_context ( 24 File "/usr/local/lib/python3.10/site-packages/playwright/sync_api/_generated.py", line 14691, in launch_persistent_context 25 self._sync( 26 File "/usr/local/lib/python3.10/site-packages/playwright/_impl/_sync_base.py", line 104, in _sync 27 return task.result() 28 File "/usr/local/lib/python3.10/site-packages/playwright/_impl/_browser_type.py", line 155, in launch_persistent_context 29 from_channel(await self._channel.send("launchPersistentContext", params)), 30 File "/usr/local/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 44, in send 31 return await self._connection.wrap_api_call( 32 File "/usr/local/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 419, in wrap_api_call 33 return await cb() 34 File "/usr/local/lib/python3.10/site-packages/playwright/_impl/_connection.py", line 79, in inner_send 35 result = next(iter(done)).result() 36 playwright._impl._api_types.Error: Chromium distribution 'chrome' is not found at /opt/google/chrome/chrome 37 Run "playwright install chrome" 38 root@a45ac5bafe65:/project/src# playwright install chrome 39 ++ arch 40 + [[ aarch64 == \a\a\r\c\h\6\4 ]] 41 + echo 'ERROR: not supported on Linux Arm64' 42 ERROR: not supported on Linux Arm64 43 + exit 1 44 Failed to install browsers 45 Error: Failed to install chrome 46 root@a45ac5bafe65:/project/src# pip list 47 Package Version 48 ----------------- ------- 49 greenlet 2.0.1 50 pip 21.2.4 51 playwright 1.31.1 52 pyee 9.0.4 53 setuptools 57.5.0 54 typing_extensions 4.5.0 55 wheel 0.37.0 56 WARNING: You are using pip version 21.2.4; however, version 23.0.1 is available. 57 You should consider upgrading via the '/usr/local/bin/python -m pip install --upgrade pip' command. 58 root@a45ac5bafe65:/project/src# playwright install chrome 59 ++ arch 60 + [[ aarch64 == \a\a\r\c\h\6\4 ]] 61 + echo 'ERROR: not supported on Linux Arm64' 62 ERROR: not supported on Linux Arm64 63 + exit 1 64 Failed to install browsers 65 Error: Failed to install chrome 66 root@a45ac5bafe65:/project/src# /usr/local/bin/python -m pip install --upgrade pip 67 Requirement already satisfied: pip in /usr/local/lib/python3.10/site-packages (21.2.4) 68 Collecting pip 69 Downloading pip-23.0.1-py3-none-any.whl (2.1 MB) 70 |████████████████████████████████| 2.1 MB 273 kB/s 71 Installing collected packages: pip 72 Attempting uninstall: pip 73 Found existing installation: pip 21.2.4 74 Uninstalling pip-21.2.4: 75 Successfully uninstalled pip-21.2.4 76 Successfully installed pip-23.0.1 77 WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv 78 root@a45ac5bafe65:/project/src# pip list 79 Package Version 80 ----------------- ------- 81 greenlet 2.0.1 82 pip 23.0.1 83 playwright 1.31.1 84 pyee 9.0.4 85 setuptools 57.5.0 86 typing_extensions 4.5.0 87 wheel 0.37.0 88 root@a45ac5bafe65:/project/src# playwright install chrome 89 ++ arch 90 + [[ aarch64 == \a\a\r\c\h\6\4 ]] 91 + echo 'ERROR: not supported on Linux Arm64' 92 ERROR: not supported on Linux Arm64 93 + exit 1 94 Failed to install browsers 95 Error: Failed to install chrome 96 root@a45ac5bafe65:/project/src#
这个运行错误,我问了一下朋友,说我的镜像要换成AMD64的。做出以下修改:
首先修改Dockerfile:
从这样:
1 FROM python:3.10 2 3 WORKDIR ./project 4 5 ADD . . 6 7 RUN pip install -r requirements.txt 8 9 CMD ["python", "./src/tian_mao.py"]
改为这样:
1 FROM python:3.10@sha256:9248825931c95c1924799cc743fd09922a088f99fb9eeeebdb6ea320bc49b440 2 3 WORKDIR ./project 4 5 ADD . . 6 7 RUN pip install -r requirements.txt 8 9 CMD ["python", "./src/tian_mao.py"]
然后删除之前打包好的压缩包和镜像以及运行的container,重新创建:
1 (base) kaka@KakadeMacBook-Pro project % rm -r -f playwright_tianmao.tar 2 (base) kaka@KakadeMacBook-Pro project % ls 3 Dockerfile requirements.txt src 4 (base) kaka@KakadeMacBook-Pro project % docker images 5 REPOSITORY TAG IMAGE ID CREATED SIZE 6 python/playwright_tianmao 3.10 24afb40d4b24 41 minutes ago 1.01GB 7 clickhouse/clickhouse-server <none> 854810a3ea35 2 months ago 705MB 8 redis alpine 7bf9ac7d3b84 3 months ago 28.1MB 9 mysql/mysql-server 8.0 55af6abb77a6 4 months ago 527MB 10 fp2_0-8.1/app latest 53b297f8c7a6 7 months ago 1.61GB 11 clickhouse/clickhouse-server latest d846490c0466 14 months ago 794MB 12 prom/prometheus latest ccf2871d6122 14 months ago 198MB 13 grafana/grafana-enterprise latest 05048bc21afe 15 months ago 290MB 14 prom/alertmanager latest 44a71f29f42b 18 months ago 55.3MB 15 (base) kaka@KakadeMacBook-Pro project % docker rmi 24afb40d4b24 16 Error response from daemon: conflict: unable to delete 24afb40d4b24 (must be forced) - image is being used by stopped container a45ac5bafe65 17 (base) kaka@KakadeMacBook-Pro project % docker ps -a 18 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 19 a45ac5bafe65 python/playwright_tianmao:3.10 "/bin/bash" 18 minutes ago Exited (130) 2 minutes ago festive_ramanujan 20 0371989e2ccb clickhouse/clickhouse-server:latest "/entrypoint.sh" 4 weeks ago Exited (0) 19 hours ago clickhouse 21 22d0abe7fe04 grafana/grafana-enterprise "/run.sh" 4 weeks ago Exited (0) 19 hours ago grafana 22 d7924246eb35 prom/prometheus "/bin/prometheus --c…" 4 weeks ago Exited (0) 19 hours ago prometheus 23 b6131d8861f1 prom/alertmanager "/bin/alertmanager -…" 4 weeks ago Exited (0) 19 hours ago altermanager 24 82c9f637311f fp2_0-8.1/app "start-container" 5 weeks ago Exited (137) About an hour ago fp20-fp2_0.test-1 25 3d682d5ba9e9 mysql/mysql-server:8.0 "/entrypoint.sh mysq…" 5 weeks ago Exited (0) About an hour ago fp20-mysql-1 26 0bc71d69051a redis:alpine "docker-entrypoint.s…" 3 months ago Exited (0) About an hour ago fp20-redis-1 27 (base) kaka@KakadeMacBook-Pro project % docker rm -f a45ac5bafe65 28 a45ac5bafe65 29 (base) kaka@KakadeMacBook-Pro project % docker ps -a 30 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 31 0371989e2ccb clickhouse/clickhouse-server:latest "/entrypoint.sh" 4 weeks ago Exited (0) 19 hours ago clickhouse 32 22d0abe7fe04 grafana/grafana-enterprise "/run.sh" 4 weeks ago Exited (0) 19 hours ago grafana 33 d7924246eb35 prom/prometheus "/bin/prometheus --c…" 4 weeks ago Exited (0) 19 hours ago prometheus 34 b6131d8861f1 prom/alertmanager "/bin/alertmanager -…" 4 weeks ago Exited (0) 19 hours ago altermanager 35 82c9f637311f fp2_0-8.1/app "start-container" 5 weeks ago Exited (137) About an hour ago fp20-fp2_0.test-1 36 3d682d5ba9e9 mysql/mysql-server:8.0 "/entrypoint.sh mysq…" 5 weeks ago Exited (0) About an hour ago fp20-mysql-1 37 0bc71d69051a redis:alpine "docker-entrypoint.s…" 3 months ago Exited (0) About an hour ago fp20-redis-1 38 (base) kaka@KakadeMacBook-Pro project % docker rmi 24afb40d4b24 39 Untagged: python/playwright_tianmao:3.10 40 Deleted: sha256:24afb40d4b24680a88e380cb6ff4dcb7f0d558fa892a7a630ef601457a8ef794 41 (base) kaka@KakadeMacBook-Pro project % docker images 42 REPOSITORY TAG IMAGE ID CREATED SIZE 43 clickhouse/clickhouse-server <none> 854810a3ea35 2 months ago 705MB 44 redis alpine 7bf9ac7d3b84 3 months ago 28.1MB 45 mysql/mysql-server 8.0 55af6abb77a6 4 months ago 527MB 46 fp2_0-8.1/app latest 53b297f8c7a6 7 months ago 1.61GB 47 clickhouse/clickhouse-server latest d846490c0466 14 months ago 794MB 48 prom/prometheus latest ccf2871d6122 14 months ago 198MB 49 grafana/grafana-enterprise latest 05048bc21afe 15 months ago 290MB 50 prom/alertmanager latest 44a71f29f42b 18 months ago 55.3MB 51 (base) kaka@KakadeMacBook-Pro project % docker build -t python/playwright_tianmao:3.10 . 52 [+] Building 231.6s (9/9) FINISHED 53 => [internal] load build definition from Dockerfile 0.0s 54 => => transferring dockerfile: 234B 0.0s 55 => [internal] load .dockerignore 0.0s 56 => => transferring context: 2B 0.0s 57 => [internal] load metadata for docker.io/library/python:3.10@sha256:9248825931c95c1924799cc743fd09922a088f99fb9eeeebdb6ea320bc49b440 50.1s 58 => [1/4] FROM docker.io/library/python:3.10@sha256:9248825931c95c1924799cc743fd09922a088f99fb9eeeebdb6ea320bc49b440 128.1s 59 => => resolve docker.io/library/python:3.10@sha256:9248825931c95c1924799cc743fd09922a088f99fb9eeeebdb6ea320bc49b440 0.0s 60 => => sha256:9248825931c95c1924799cc743fd09922a088f99fb9eeeebdb6ea320bc49b440 2.22kB / 2.22kB 0.0s 61 => => sha256:167c7feebee855d117e192389484ea8367be1ba84e7ee35f4e5e5663195facbf 5.17MB / 5.17MB 10.8s 62 => => sha256:c5f645e92da603500d33bc8fc68e56f3f099a42df5ac6a0555aca1d97eb2b295 8.83kB / 8.83kB 0.0s 63 => => sha256:32fb02163b6bb519a30f909008e852354dae10bdfd6b34190dbdfe8f15403ea0 55.05MB / 55.05MB 34.1s 64 => => sha256:d6dfff1f6f3ddd2194ea0775f199572e8b2d75c38713eef0444d6b1fd0ac7604 10.88MB / 10.88MB 14.9s 65 => => sha256:e9cdcd4942ebc7445d8a70117a83ecbc77dcc5ffc72c4b6f8e24c0c76cfee15d 54.59MB / 54.59MB 37.8s 66 => => sha256:ca3bce705f6c47c25b6e7896b4da514bf271c5827b1d19f51611c4a149dd713c 196.81MB / 196.81MB 123.4s 67 => => sha256:5e1c6c4f8bbf1116f692204567222e5b77b4d0275cccad0c6810eb4374aede6a 6.29MB / 6.29MB 41.4s 68 => => extracting sha256:32fb02163b6bb519a30f909008e852354dae10bdfd6b34190dbdfe8f15403ea0 1.4s 69 => => extracting sha256:167c7feebee855d117e192389484ea8367be1ba84e7ee35f4e5e5663195facbf 0.1s 70 => => extracting sha256:d6dfff1f6f3ddd2194ea0775f199572e8b2d75c38713eef0444d6b1fd0ac7604 0.1s 71 => => sha256:e7e563b10921e18f084671abbc971288264b26ab41576541c7b116fc14c0c556 18.68MB / 18.68MB 67.2s 72 => => extracting sha256:e9cdcd4942ebc7445d8a70117a83ecbc77dcc5ffc72c4b6f8e24c0c76cfee15d 1.6s 73 => => sha256:9eb9d866c104c549ac94ce83566922769ffe81937a9e658d8399eeb922daeaf4 233B / 233B 46.7s 74 => => sha256:8ca602e7301aa8df1eed99ae3b3cc211b906d6e9ac1ed474b5caade83cdc428c 3.06MB / 3.06MB 53.4s 75 => => extracting sha256:ca3bce705f6c47c25b6e7896b4da514bf271c5827b1d19f51611c4a149dd713c 3.5s 76 => => extracting sha256:5e1c6c4f8bbf1116f692204567222e5b77b4d0275cccad0c6810eb4374aede6a 0.2s 77 => => extracting sha256:e7e563b10921e18f084671abbc971288264b26ab41576541c7b116fc14c0c556 0.4s 78 => => extracting sha256:9eb9d866c104c549ac94ce83566922769ffe81937a9e658d8399eeb922daeaf4 0.0s 79 => => extracting sha256:8ca602e7301aa8df1eed99ae3b3cc211b906d6e9ac1ed474b5caade83cdc428c 0.1s 80 => [internal] load build context 0.0s 81 => => transferring context: 6.68kB 0.0s 82 => [2/4] WORKDIR ./project 0.1s 83 => [3/4] ADD . . 0.0s 84 => [4/4] RUN pip install -r requirements.txt 52.7s 85 => exporting to image 0.4s 86 => => exporting layers 0.4s 87 => => writing image sha256:2f87500db3333bdb7de9cac21b3db0cb2fb07e97731b9b0a6a15fecd8b298562 0.0s 88 => => naming to docker.io/python/playwright_tianmao:3.10 0.0s 89 90 Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them 91 (base) kaka@KakadeMacBook-Pro project % docker save -o playwright_tianmao.tar python/playwright_tianmao 92 (base) kaka@KakadeMacBook-Pro project % docker run -t -i python/playwright_tianmao:3.10 /bin/bash 93 WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8) and no specific platform was requested 94 root@e7de99386313:/project#
又有问题了,好烦
标签:ago,playwright,MB,Python,months,project,Mac,Docker,sha256 From: https://www.cnblogs.com/kaka0318/p/17191654.html