我创建了一个码头形象来运行剧作家:
FROM ubuntu:20.04
ENV PLAYWRIGHT_BROWSERS_PATH /browsers
ENV PYTHONV 3.8
RUN echo '-----> Installing Necessary Libraries & Packages' && \
export DEBIAN_FRONTEND=noninteractive && \
apt-get update && \
apt-get install -y --no-install-recommends python${PYTHONV} python${PYTHONV}-distutils curl python3-dev build-essential python3-venv ffmpeg && \
curl https://bootstrap.pypa.io/get-pip.py | python3 && \
apt-get autoremove -y && \
mkdir /browsers && chmod 777 /browsers && \
echo '-----> Library & Package Installation Complete'
RUN echo '-----> Installing Playwright for Python' && \
pip install playwright && \
pip install pytest-playwright && \
playwright install chromium && \
echo '-----> Playwright for Python Installation Complete'
RUN echo '-----> Installing Playwright System Dependancies' && \
DEBIAN_FRONTEND=noninteractive playwright install-deps && \
echo '-----> Playwright System Dependancies Complete'
RUN mkdir /app
COPY . /app
WORKDIR /app
RUN pip install -r requirements.txt
CMD ["PLAYWRIGHT_BROWSERS_PATH=/browsers","python3","/app/main.py"]
一切都很好,但是当我去运行映像时,我会得到这个错误。
user@user-VirtualBox:/media/sf_MyFolder$ docker run -t fetchtest
docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: exec: "PLAYWRIGHT_BROWSERS_PATH=/browsers": stat PLAYWRIGHT_BROWSERS_PATH=/browsers: no such file or directory: unknown.
奇怪的是,我决定查看容器文件夹,以检查它是否真的丢失了如下所示:
docker run -t fetchtest /bin/bash
但我根本不能运行任何命令。每当我尝试运行命令(如cd /browsers
)时,它都会挂起
user@user-VirtualBox:/media/sf_FetchItForMe$ docker run -t fetchtest /bin/bash
root@13adf854bf6e:/app# ls
█
我得关闭终点站才能出去。我不能使用exit()或任何东西。这是我的码头信息:
user@user-VirtualBox:/media/sf_MyFolder$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
fetchtest latest aaaaaaaaaaaa 2 hours ago 1.9GB
ubuntu 20.04 aaaaaaaaaaaa 5 days ago 72.8MB
user@user-VirtualBox:/media/sf_MyFolder$ docker info
Client:
Context: default
Debug Mode: false
Plugins:
app: Docker App (Docker Inc., v0.9.1-beta3)
buildx: Docker Buildx (Docker Inc., v0.8.2-docker)
compose: Docker Compose (Docker Inc., v2.6.1)
extension: Manages Docker extensions (Docker Inc., v0.2.7)
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
scan: Docker Scan (Docker Inc., v0.17.0)
Server:
Containers: 6
Running: 0
Paused: 0
Stopped: 6
Images: 19
Server Version: 20.10.17
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Native Overlay Diff: false
userxattr: true
Logging Driver: json-file
Cgroup Driver: none
Cgroup Version: 1
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
runc version: v1.1.4-0-g5fd4c4d
init version: de40ad0
Security Options:
seccomp
Profile: default
rootless
Kernel Version: 5.15.0-46-generic
Operating System: Ubuntu 20.04.5 LTS
OSType: linux
Architecture: x86_64
CPUs: 1
Total Memory: 7.67GiB
Name: user-VirtualBox
Docker Root Dir: /home/user/.local/share/docker
Debug Mode: false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
127.0.0.0/8
Live Restore Enabled: false
WARNING: Running in rootless-mode without cgroups. To enable cgroups in rootless-mode, you need to boot the system in cgroup v2 mode.
为什么会发生这种情况?
发布于 2022-09-07 03:26:00
这是:
CMD ["PLAYWRIGHT_BROWSERS_PATH=/browsers","python3","/app/main.py"]
是一个无效的命令。当您使用JSON格式的CMD
语句时,这些命令是直接执行的,没有shell,所以不能使用VAR=value somecommand ...
这样的shell语法。
按照编写CMD
的方式,Docker正在尝试执行一个名为PLAYWRIGHT_BROWSERS_PATH=/browsers
的命令,这个命令当然不存在。
如果要设置环境变量,请使用ENV
命令:
ENV PLAYWRIGHT_BROWSERS_PATH=/browsers
CMD ["python3", "/app/main.py"]
https://stackoverflow.com/questions/73629714
复制相似问题