Questions tagged shell

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

Grep does not show color even when using –color=always

Grep usually shows highlighted text in red which is what I wanted but this time it doesn’t seem to do that no matter what I do. I am doing this from a Docker container (nginx:1.19-alpine more specifically) and I installed Bash 5.1 using RUN apk add bash. Then I added a ~/.bashrc config file with […]

By martins16321
Published
Categorised as bash, docker, grep, linux, shell Tagged , , , ,

How to add a user (including password file entry) during docker run (not docker build)

I have a generic development environment container and I want to be able to add the host user’s EUID, host home directory, and password file entry when I run the container so the user has access to his actual host home directory mounted (or copied into the container), config files, personal utilities etc. I have […]

By Walt Howard
Published
Categorised as authentication, docker, shell Tagged , ,

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 , , ,
1 31

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