executing shell command in docker composer gives me error

defekas17

I'm trying to execute shell command in docker-compose.yml. Code is:

    command: bash -c mkdir /opt/wa/usr/install_templates

When I do:

    sudo docker-compose up  serviceA

it gives me :

    serviceA     | mkdir: missing operand
tentative

When you use bash -c, it runs the first string after the -c flag. See this SO answer for more information. Docker is reading your command bash -c mkdir /path/ and your bash command is just running mkdir in a bash subshell, causing that error.

You don't need to put bash -c before your commands in a docker-compose file. The Docker engine will handle running it in a shell for you and you can simply write the command you want to be run. I'd suggest replacing your command with this:

command: mkdir /opt/wa/usr/install_templates

Alternatively, you could try putting the entire command into a string if you want to force the command to be run in bash:

command: bash -c "mkdir /opt/wa/usr/install_templates"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Getting the (parent) process executing the command in Linux shell

From Dev

Trying to search changeset using the command tfpt searchcs in command utility gives me TF30012 error

From Dev

Executing long command with groovy on linux shell?

From Dev

Executing shell command not working in AWS

From Dev

Executing a basic shell command in Elixir

From Dev

Executing shell mail command using python

From Dev

bash script - executing find command gives no output

From Dev

curl command not executing via shell script in bash

From Dev

Executing Shell command in Makefile rule

From Dev

Error executing command, exiting

From Dev

Shell command not executing in Java

From Dev

Error executing shell script

From Dev

Error executing command, exiting

From Dev

Installing symfony with composer gives error

From Dev

Executing shell command not working in AWS

From Dev

MySQL 'AND' gives me error

From Dev

It gives me an error at GPS

From Dev

executing shell command using shell script

From Dev

bash script - executing find command gives no output

From Dev

ionCube shell script gives error

From Dev

rsync gives an error in shell script

From Dev

Executing PHP gives error on command line interface, but works in browser

From Dev

Error when executing tcpdump command

From Dev

Error while executing awk command in shell script

From Dev

Executing Shell command in Makefile rule

From Dev

rbenv gives me to long error report in shell when something happens with my rails app

From Dev

Bash syntax error executing command in Ruby, but it works in shell

From Dev

fuse 7 : Error executing command: by zero : when docker images is created

From Dev

Composer Autoload gives error "Class not found"

Related Related

HotTag

Archive