While executing the run command, I'm getting syntax error as follows:
> [10/10] RUN ./download_files.sh:
#15 0.285 ./download_files.sh: 5: ./download_files.sh: Syntax error: "(" unexpected
------
executor failed running [/bin/sh -c ./download_files.sh]: exit code: 2
The Shell script contents are as follows:
#!/bin/sh
mkdir pretrained_models
cd pretrained_models
declare -a StringArray=("https://zenodo.org/record/4751737/files/BC-DeepLIIF_Training_Set.zip" "https://zenodo.org/record/4751737/files/BC-DeepLIIF_Validation_Set.zip" "https://zenodo.org/record/4751737/files/DeepLIIF_BC_Model.zip" "https://zenodo.org/record/4751737/files/DeepLIIF_Latest_Model.zip" "https://zenodo.org/record/4751737/files/DeepLIIF_Testing_Set.zip" "https://zenodo.org/record/4751737/files/DeepLIIF_Training_Set.zip" "https://zenodo.org/record/4751737/files/DeepLIIF_Validation_Set.zip" "https://zenodo.org/record/4751737/files/Evaluation_Excel_Files.zip")
for val in ${StringArray[#]}; do
exec wget $val
done
Related
I've got this in a docker build file: RUN 'echo "y" | /usr/bin/task'
When building, this error is thrown:
=> ERROR [tool_config 9/11] RUN 'echo "y" | /usr/bin/task' 0.2s
------
> [tool_config 9/11] RUN 'echo "y" | /usr/bin/task':
#15 0.164 /bin/sh: echo "y" | /usr/bin/task: not found
------
executor failed running [/bin/sh -c 'echo "y" | /usr/bin/task']: exit code: 127
The command runs fine when manually run from insside the container. The task command is definitely installed.
Without without quotes, RUN echo "y" | task gives:
=> ERROR [tool_config 9/11] RUN echo "y" | /usr/bin/task 0.2s
------
> [tool_config 9/11] RUN echo "y" | /usr/bin/task:
#15 0.176 A configuration file could not be found in /root
#15 0.176
#15 0.176 Would you like a sample /root/.taskrc created, so Taskwarrior can proceed? (yes/no) No matches.
------
executor failed running [/bin/sh -c echo "y" | /usr/bin/task]: exit code: 1
The problem was the task command was returning "No matches" because no tasks had yet been created so the command exited with an error code of 1 and docker choked.
Fix is simple as per https://stackoverflow.com/a/30717108/1641112:
RUN echo "y" | task; exit 0;
I'm trying to use scripts of Composer with quotes to pass an environment variable to the command that will be run with Docker.
I use sh -c 'A=b [command]' in order to run a command with an environment variable.
Here is a minimal example:
{
"scripts": {
"docker-run": "docker run --tty composer:2",
"docker-version": "#docker-run composer --version",
"docker-version2": "#docker-run sh -c 'CONSTANT=6.2.x-dev composer --version'"
}
}
When I run it, the script docker-version works as expected:
$ composer run-script docker-version
> docker run --tty composer:2 'composer' '--version'
Composer version 2.3.10 2022-07-13 15:48:23
But the script docker-version2 fails. The simple quotes are escaped and it breaks the command:
$ composer run-script docker-version2
> docker run --tty composer:2 'sh' '-c' ''\''CONSTANT=6.2.x-dev' 'composer' '--version'\'''
composer: line 0: syntax error: unterminated quoted string
Script docker run --tty composer:2 handling the docker-run event returned with error code 2
Script #docker-run sh -c 'CONSTANT=6.2.x-dev composer --version' was called via docker-version2
You can set environment variables with env command.
docker-run env CONSTANT=6.2.x-dev composer --version
If I run two commands:
export TMPCMD='sh -c "if [ `uname -m` = aarch64 ]; then echo 0; fi"'
docker exec container sh -c "..."
It produces an error:
[: 1: [: Syntax error: Unterminated quoted string
How might I fix this?
So far I have tried I could not find to execute like docker exec container sh -c "..."
Alternatively, You can create a shell script file name example Stackoverflow.sh
Dockerfile
FROM nginx:latest
COPY Stackoverflow.sh bin/Stackoverflow.sh
RUN chmod u+x bin/Stackoverflow.sh
RUN bin/Stackoverflow.sh
docker exec -it <conyainer-ID> bash
root#<conyainer-ID>:/bin# ./Stackoverflow.sh
#=>Logging-Container has started.
#=>Check uname -m command.
#=>0
Hope this help you.
I want to use docker-abuild to build imagemagick in a Dockerfile. I use the following in the Dockerfile:
FROM alpinelinux/docker-abuild as imagickbuilder
COPY imagick/APKBUILD.imagick /home/builder/package/APKBUILD
COPY imagick/APKBUILD.imagick /home/builder/APKBUILD
COPY imagick/disable-avaraging-tests.patch /home/builder/package/disable-avaraging-tests.patch
COPY imagick/webmaster#mycompany.com-5b42f8ed.rsa /home/builder/ssh.rsa
COPY imagick/webmaster#mycompany.com-5b42f8ed.rsa.pub /etc/apk/keys/ssh.rsa.pub
ARG DABUILD_ARCH=aarch64
RUN dabuild -r
# tried abuild -r as well as builder -r
Regardless of what APKBUILD file I have/use, I'm getting the following error while building with docker build -t test .:
#...
#11 [7/7] RUN dabuild -r
#11 sha256:8c6e0fa4c055b4f5bbb7f633a3b4b4009cda31017a26dc48a047fd02466ce60c
#11 0.658 /bin/sh: dabuild: not found
#11 ERROR: executor failed running [/bin/sh -c dabuild -r]: exit code: 127
------
> [7/7] RUN dabuild -r:
------
executor failed running [/bin/sh -c dabuild -r]: exit code: 127
I'm getting the same error with abuild -r and abuilder -r. Any ideas?
JFYI, I'm running this under macOS Monterey 12.2.1 with an M1 Pro MacBook Pro.
When issuing grunt shell:test, I'm getting warning "the input device is not a TTY" & don't want to have to use -f:
$ grunt shell:test
Running "shell:test" (shell) task
the input device is not a TTY
Warning: Command failed: /bin/sh -c ./run.sh npm test
the input device is not a TTY
Use --force to continue.
Aborted due to warnings.
Here's the Gruntfile.js command:
shell: {
test: {
command: './run.sh npm test'
}
Here's run.sh:
#!/bin/sh
# should use the latest available image to validate, but not LATEST
if [ -f .env ]; then
RUN_ENV_FILE='--env-file .env'
fi
docker run $RUN_ENV_FILE -it --rm --user node -v "$PWD":/app -w /app yaktor/node:0.39.0 $#
Here's the relevant package.json scripts with command test:
"scripts": {
"test": "mocha --color=true -R spec test/*.test.js && npm run lint"
}
How can I get grunt to make docker happy with a TTY? Executing ./run.sh npm test outside of grunt works fine:
$ ./run.sh npm test
> yaktor#0.59.2-pre.0 test /app
> mocha --color=true -R spec test/*.test.js && npm run lint
[snip]
105 passing (3s)
> yaktor#0.59.2-pre.0 lint /app
> standard --verbose
Remove the -t from the docker run command:
docker run $RUN_ENV_FILE -i --rm --user node -v "$PWD":/app -w /app yaktor/node:0.39.0 $#
The -t tells docker to configure the tty, which won't work if you don't have a tty and try to attach to the container (default when you don't do a -d).
This solved an annoying issue for me. The script had these lines:
docker exec **-it** $( docker ps | grep mysql | cut -d' ' -f1) mysql --user= ..... > /var/tmp/temp.file
mutt -s "File is here" someone#somewhere.com < /var/tmp/temp.file
The script would run great if run directly and the mail would come with the correct output. However, when run from cron, (crontab -e) the mail would come with no content. Tried many things around permissions and shells and paths etc. However no joy!
Finally found this:
*/20 * * * * scriptblah.sh > $HOME/cron.log 2>&1
And on that cron.log file found this output:
the input device is not a TTY
Search led me here. And after I removed the -t, it's working great now!
docker exec **-i** $( docker ps | grep mysql | cut -d' ' -f1) mysql --user= ..... > /var/tmp/temp.file