Search code examples
bashshellwhile-loopdockerdouble-quotes

Unable to run shell command with docker?


I have installed docker on Ubuntu 14.04. Now when i am trying to create one test job in docker, i am getting the below error:

$ sample_job=$(docker run -d busybox /bin/sh -c “while true; do echo Docker; sleep 1; done”)

-bash: command substitution: line 228: syntax error near unexpected token `do'

-bash: command substitution: line 228: `docker run -d busybox /bin/sh -c “while true; do echo Docker; sleep 1; done”)'

I am following the below blog for starting with docker: http://blog.flux7.com/blogs/docker/docker-tutorial-series-part-2-the-15-commands

Could someone help me in resolving this issue. Thanks!!


Solution

  • Credit goes to Cyrus:

    Replaced by "

    $ sample_job=$(docker run -d busybox /bin/sh -c "while true; do echo Docker; sleep 1; done")