如何进入 Dart Docker 容器的 shell?
How to get into Dart Docker container's shell?
我正在尝试访问我的 Dart Docker 容器的 shell
$ docker-compose exec dartserver sh
但我收到此错误消息:
OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "sh": executable file not found in $PATH: unknown
有什么想法吗?
Dockerfile
FROM dart:stable AS build
# Resolve app dependencies.
WORKDIR /app
COPY pubspec.* ./
RUN dart pub get
# Copy app source code (except anything in .dockerignore) and AOT compile app.
COPY . .
RUN dart compile exe bin/server.dart -o bin/server
# Build minimal serving image from AOT-compiled `/server`
# and the pre-built AOT-runtime in the `/runtime/` directory of the base image.
FROM scratch
COPY --from=build /runtime/ /
COPY --from=build /app/bin/server /app/bin/
# Start server.
EXPOSE 8080
CMD ["/app/bin/server"]
scratch
图片默认没有 shell
。如果你真的想访问shell,我建议使用busybox image.
参见busybox
dockerfile:
FROM scratch
ADD busybox.tar.xz /
CMD ["sh"]
也是基于scratch的,但是shell启用了,另外还是很小
我正在尝试访问我的 Dart Docker 容器的 shell
$ docker-compose exec dartserver sh
但我收到此错误消息:
OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "sh": executable file not found in $PATH: unknown
有什么想法吗?
Dockerfile
FROM dart:stable AS build
# Resolve app dependencies.
WORKDIR /app
COPY pubspec.* ./
RUN dart pub get
# Copy app source code (except anything in .dockerignore) and AOT compile app.
COPY . .
RUN dart compile exe bin/server.dart -o bin/server
# Build minimal serving image from AOT-compiled `/server`
# and the pre-built AOT-runtime in the `/runtime/` directory of the base image.
FROM scratch
COPY --from=build /runtime/ /
COPY --from=build /app/bin/server /app/bin/
# Start server.
EXPOSE 8080
CMD ["/app/bin/server"]
scratch
图片默认没有 shell
。如果你真的想访问shell,我建议使用busybox image.
参见busybox
dockerfile:
FROM scratch
ADD busybox.tar.xz /
CMD ["sh"]
也是基于scratch的,但是shell启用了,另外还是很小