Questions tagged shell

Explore the latest questions and answers asked by our top developers.

sh: : unknown operand when running shell script via docker [duplicate]

#!/bin/sh while : do if [[ $(find . -type f -name "*.zip") ]]; then calling_other_function else break fi done When I run these lines of code using bash terminal it works as it should. But when I run this file via docker, I get this error: sh: : unknown operand Here I trying to check […]

By tapas kumar
Published
Categorised as alpine-package-keeper, bash, docker, sh, shell Tagged , , , ,

why do I always get a syntax error in shell script running inside a container [duplicate]

I’m trying to run a shell script to build a docker image, but always getting a error that I cannot correct: Neomind_dev | build.sh: line 3: syntax error near unexpected token `$’r” ‘eomind_dev | build.sh: line 3: `fi but the code is super simple: if [ ! "$(ls /usr/local/fusion)" ]; then echo aaa fi cp […]

By Lucas Fellipe Mondini Pereira
Published
Categorised as docker, shell Tagged ,

Setting env variable of container through bash script is not working

I’m trying to set a env variable of a docker container through bash script. CMD ["/bin/bash", "-c","source runservice.sh"] runservice.sh #!/usr/bin/env bash export "foo"="bar" Now after pushing it when I go inside the container and do printenv, it is not setting up environment variable. But if I run the same command inside the container, env variable […]

By Rishav Raj
Published
Categorised as bash, docker, docker-compose, sh, shell Tagged , , , ,

Setting enviroment variable of the container through bash script is not working

I’m trying to set a enviroment variable of a docker container through bash script. CMD ["/bin/bash", "-c","source runservice.sh"] runservice.sh #!/usr/bin/env bash export "foo"="bar" Now after pushing it when I go inside the container and do printenv, it is not setting up enviroment variable. But if I run the same command inside the container, env variable […]

By Rishav Raj
Published
Categorised as bash, docker, docker-compose, sh, shell Tagged , , , ,

How to access docker container’s shell from a remote machine

A docker container is running in a headless Ubuntu machine. We are looking to access the shell of the docker from a remote machine connected to the LAN of the host Ubuntu machine. SSH is not an option since the docker container does not support it. Please help. Thanks in advance Source: Docker Questions

By Jishnu Anilkumar
Published
Categorised as console, docker, shell, ubuntu Tagged , , ,

Syntax error while running shell script via Dockerfile

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" […]

By Amogh Joshi
Published
Categorised as docker, dockerfile, shell Tagged , ,

Get container id of another container in the same network

I have a docker-compose setup for 13 of my services that runs before my test container. Here are the steps for the same: use profile services to pull service images from GCR profile services compose up build and run in background wait for all services health and then run the test container with exit code […]

By Sankalan Parajuli
Published
Categorised as bash, docker, docker-compose, shell Tagged , , ,

Interactice shell in docker, docker-compose, check if tty is connected,check for stdin, stdout, stderr

recently I learned something about using tty in docker. I run a shell script in a docker container and want to read from stdin to provide something interactively when attached to the container. If you just use the command read -p "> " -r line you will get 100% cpu load, if there is no […]

By MarkusH1975
Published
Categorised as bash, docker, linux, shell Tagged , , ,

How to get into Dart Docker container’s shell?

I’m trying to access the my Dart Docker container’s shell $ docker-compose exec dartserver sh but I’m getting this error message: OCI runtime exec failed: exec failed: container_linux.go:380: starting container process caused: exec: "sh": executable file not found in $PATH: unknown Any idea? Dockerfile FROM dart:stable AS build # Resolve app dependencies. WORKDIR /app COPY […]

By
Published
Categorised as dart, docker, docker-compose, sh, shell Tagged , , , ,

How to send a command properly into docker container?

I can execute the command below in my terminal succesfully. command: gdalwarp -s_srs "+datum=WGS84 +no_defs +geoidgrids=egm96-15.gtx" -t_srs "+datum=WGS84 +no_def" input.tif output.tif Now, I want to store this command into a variable and expand this command inside a docker container. My script run.sh looks like the following. I first store my target command into mycommand and […]

By Lion Lai
Published
Categorised as bash, docker, double-quotes, shell, syntax Tagged , , , ,
1 2 3 37

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq