[英]How to execute shell script within a docker container
我有一個Docker容器,該容器在啟動時執行一個shell腳本(startService.sh),該腳本使用“ source” linux關鍵字(我的docker容器不喜歡)。 運行映像時,我看到以下錯誤消息:
./startService.sh:6:./startService.sh:源:找不到
為什么會看到此錯誤? 不能在映像的腳本中使用“ source” linux命令嗎?
Dockerfile:
FROM openjdk:8
VOLUME /opt/att/ajsc/config
COPY startService.sh /startService.sh
RUN chmod 777 /startService.sh
ENTRYPOINT ./startService.sh
startService.sh
#!/bin/sh
export AJSC_HOME=/opt/att/ajsc
export AJSC_CONFIG_HOME=${AJSC_HOME}/config
source /opt/att/ajsc/etc/config /run.source
source
是bash
的命令,但sh
沒有。 在sh
,使用單點.
。 單點.
也可以使用bash
。
您的腳本具有shebang #!/bin/sh
。 用替換source
.
,或將#!/bin/sh
替換為#!/bin/bash
。
(此問題與泊塢窗無關。)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.