为什么使用.SH脚本作为入口点时,为什么Docker无法运行正确的CMD?
我对Docker的新手(至少要比其他人构建的图像还要多),并且我陷入了这一模型。我正在使用Deno构建一个应用程序,并试图在Docker中运行它。我的基本形象是官员使用Alpine 的Deno图像,它使用.SH作为入口点。官方图像中定义的输入点脚本应该查看CMD中的第一个参数(在这种情况下为“运行”),如果它在列表中(它是),请使用DENO命令运行。相反,我有一个错误。
CMD
CMD run --allow-net --allow-read --lock=lock.json mod.ts
错误
/bin/sh: run: not found
当我在DENO中进行硬码时,
运行良好。 cmd deno run - allow-net - allow-read-lock = lock.json mod.ts
我不知道为什么它不通过脚本作为入口点来工作。我在做什么错?
docker-entry.sh
#!/bin/sh
set -e
if [ "$1" != "${1#-}" ]; then
# if the first argument is an option like `--help` or `-h`
exec deno "$@"
fi
case "$1" in
bundle | cache | compile | completions | coverage | doc | eval | fmt | help | info | install | lint | lsp | repl | run | test | types | uninstall | upgrade | vendor )
# if the first argument is a known deno command
exec deno "$@";;
esac
exec "$@"
我的dockerfile
FROM denoland/deno:alpine-1.19.2
# The port that your application listens to.
EXPOSE MYPORTNUMBER
WORKDIR /app
# Prefer not to run as root.
USER deno
# Cache the dependencies as a layer (the following two steps are re-run only when deps.ts is modified).
# Ideally cache deps.ts will download and compile _all_ external files used in main.ts.
COPY deps.ts .
RUN deno cache deps.ts
# These steps will be re-run upon each file change in your working directory:
ADD . .
# Compile the main app so that it doesn't need to be compiled each startup/entry.
RUN deno cache mod.ts
CMD run --allow-net --allow-read --lock=lock.json mod.ts
I'm relatively new to docker (at least to do more than run images others had built) and I'm stuck on this one. I'm building an app using Deno and trying to get it running in docker. my base image is the official deno image with Alpine, which uses an .sh as its entry point. The entry point script as defined in the official image is supposed to look at the first argument in the CMD (in this case "run") and if it's in a list (which it is), run it with the deno command. Instead I get an error.
the CMD
CMD run --allow-net --allow-read --lock=lock.json mod.ts
the error
/bin/sh: run: not found
when I hard code in the deno, it runs fine.
CMD deno run --allow-net --allow-read --lock=lock.json mod.ts
I can't figure why it's not working through the script as an entry point. What am I doing wrong?
docker-entry.sh
#!/bin/sh
set -e
if [ "$1" != "${1#-}" ]; then
# if the first argument is an option like `--help` or `-h`
exec deno "$@"
fi
case "$1" in
bundle | cache | compile | completions | coverage | doc | eval | fmt | help | info | install | lint | lsp | repl | run | test | types | uninstall | upgrade | vendor )
# if the first argument is a known deno command
exec deno "$@";;
esac
exec "$@"
my Dockerfile
FROM denoland/deno:alpine-1.19.2
# The port that your application listens to.
EXPOSE MYPORTNUMBER
WORKDIR /app
# Prefer not to run as root.
USER deno
# Cache the dependencies as a layer (the following two steps are re-run only when deps.ts is modified).
# Ideally cache deps.ts will download and compile _all_ external files used in main.ts.
COPY deps.ts .
RUN deno cache deps.ts
# These steps will be re-run upon each file change in your working directory:
ADD . .
# Compile the main app so that it doesn't need to be compiled each startup/entry.
RUN deno cache mod.ts
CMD run --allow-net --allow-read --lock=lock.json mod.ts
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论