实现:
我已在我的 Windows 上使用二进制文件成功安装了 protoc
通过在环境变量中使用以下路径,
C:\Program Files\protoc-26.1-win64 中
失败:
但是,我无法通过 Dockerfile 安装协议
我尝试了什么
我已经尝试过
运行 apt-get update && apt-get install -y protobuf-compiler libprotobuf-dev
这是我得到的,当尝试通过构建Dockerfile
时docker build -t myapp .
> => ERROR [builder 2/7] RUN apt-get update && apt-get install -y
> protobuf-compiler libprotobuf-dev 0.4s
> ------
> > [builder 2/7] RUN apt-get update && apt-get install -y protobuf-compiler libprotobuf-dev:
> 0.364 /bin/sh: apt-get: not found
> ------ WARNING: current commit information was not captured by the build: git was not found in the system: exec: "git.exe": executable
> file not found in %PATH% Dockerfile:5
> -------------------- 3 | 4 | # install protobuf 5 | >>> RUN apt-get update && apt-get install -y protobuf-compiler
> libprotobuf-dev 6 | 7 | # This is important, see
> https://github.com/rust-lang/docker-rust/issues/85
> -------------------- ERROR: failed to solve: process "/bin/sh -c apt-get update && apt-get install -y protobuf-compiler
> libprotobuf-dev" did not complete successfully: exit code: 127
在 Windows 上,Docker 容器通常只是基于共享 Linux VM 内减少的 Linux 文件系统映像的隔离环境(有基于 Windows 的容器,但不太常用)。
运行 apt-get update
表示您正在尝试使用适用于基于 Debian 的环境的东西
0.364 /bin/sh: apt-get: 未找到
表示 apt-get 不可用,例如因为容器镜像不是基于 debian 的
所以弄清楚你的容器是基于什么或切换到一些 debian 或衍生图像。
您还可以通过 WSL 使用 Linux 发行版,或者至少通过执行
docker run -it --rm <image name>
来更交互式地探索这些内容