Docker Community Forums

Share and learn in the Docker community.

Docker run command only works as bash -c multi-command

docker

(Eaglegenomics) #1

Hi

We’ve been seeing oddities with some docker run commands which fail unless they are the 2nd command in a multiple command string submitted using bash -c.

With a random ‘export’ prior to a perl command:

docker run  -m 4g -l eaglegenomics/test bash -c 'export BLAH=1; perl -e "use IPC::Cmd; my \$ret = IPC::Cmd::run_forked(q(aws s3 ls s3://eagle/test_data/rna-seq/sample_reads_1.fastq.gz), {timeout => 30}); use Data::Dumper;  print q(ret  is ).Dumper(\$ret).\"\n\"";'
    ret  is $VAR1 = {
          'stderr' => '',
          'child_pgid' => 8,
          'killed_by_signal' => 0,
          'parent_died' => 0,
          'exit_code' => 0,
          'err_msg' => 'stdout:
 2015-10-29 11:22:12      44587 sample_reads_1.fastq.gz

Without the preceding ‘export’ command, perl command fails:

docker run  -m 4g -l eaglegenomics/test bash -c 'perl -e "use IPC::Cmd; my \$ret = IPC::Cmd::run_forked(q(aws s3 ls s3://eagle/test_data/rna-seq/sample_reads_1.fastq.gz), {timeout => 30}); use Data::Dumper;  print q(ret  is ).Dumper(\$ret).\"\n\"";'
ret  is $VAR1 = {
          'stderr' => '',
          'child_pgid' => 7,
          'killed_by_signal' => 0,
          'parent_died' => 0,
          'exit_code' => 0,
          'err_msg' => '',
          'timeout' => 0,
          'merged' => '',
          'stdout' => ''
        };

Note absence of file listing.

We have also seen this with other non-perl commands. Unfortunately we can’t use this workaround, as the problem is conflated due to using docker swarm manager to submit the jobs, which in our current environment, seems to have problems handling the quotes in the bash command (related post coming soon).

Can anyone enlighten me as to why this is happening? And possible solutions which don’t include a multiple command string?

Thanks in advance

Nathan Johnson


(Eaglegenomics) #2

For those having similar problems, this seems to be tied to running a forked process within the container. As using IPC::Cmd::run does not show the same issues.


(Neilhwatson) #3

I’ve noticed a similar problem using POE (https://github.com/neilhwatson/cfbot/blob/docker/cfbot.pm#L885). My code is a chatbot that forks some replies and information gathering. In docker these forks do not appear to happen.

What was your solution or workaround?