简体   繁体   中英

How to execute shell script within a docker container

I have a docker container that, at start up, executes a shell script (startService.sh), which uses the "source" linux keyword (which my docker container doesn't like). I'm seeing the error message below when running my image:

./startService.sh: 6: ./startService.sh: source: not found

Why am I seeing this error? Can one not use the "source" linux command in a script in an image?

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 is a command present in bash , but not in sh . In sh , use single dot . . The single dot . works in bash , too.

Your script has shebang #!/bin/sh . Either replace source with . , or replace #!/bin/sh with #!/bin/bash .

(This issue has nothing to do with docker.)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM