The docker task should interpret its arguments in a similar way terminal does

XMLWordPrintable

    • 2
    • Severity 3 - Minor

      Problem Definition

      Bamboo has a strategy to escape special characters in the docker task arguments and it is not similar to terminal, causing users to get confused receiving unexpected errors.

      Steps to Reproduce

      1. Build a docker image (called image) with the following docker file:
        FROM ubuntu
        RUN apt-get update
        RUN apt-get install -y wget
        ENTRYPOINT ["wget", "-O-", "-q"]
        
      2. Create a docker run task with:
        Docker image: image
        Additional arguments:--entrypoint="ls"
        
      3. Run a build

      Expected Results

      Bamboo will execute a command as if the following command was run in terminal, something similar to:

      docker run --entrypoint="ls" image
      

      the new image will run the ls command

      Actual Results

      Bamboo will execute a command similar to:

      docker run --entrypoint=\"ls\" image
      

      The docker command will fail, since the ENTRYPOINT will be set to "ls" and not only ls as it should be.

      This is the command shown in the build logs:

      /usr/local/bin/docker run --volume /Users/dsantos/atlassian/bamboo/5.15.3/home/xml-data/build-dir/DOC-DOC-JOB1:/data --workdir /data --rm --entrypoint="ls" image
      

      This is the error we get:

      error	29-Mar-2017 19:31:44	container_linux.go:247: starting container process caused "exec: \"\\\"ls\\\"\": executable file not found in $PATH"
      error	29-Mar-2017 19:31:45	/usr/local/bin/docker: Error response from daemon: oci runtime error: container_linux.go:247: starting container process caused "exec: \"\\\"ls\\\"\": executable file not found in $PATH".
      simple	29-Mar-2017 19:31:45	Failing task since return code of [/usr/local/bin/docker run --volume /Users/dsantos/atlassian/bamboo/5.15.3/home/xml-data/build-dir/DOC-DOC-JOB1:/data --workdir /data --rm --entrypoint="ls" image] was 127 while expected 0
      

      Workaround

      Understand how Bamboo works on escaping special characters and correctly set the needed arguments

      Here we can find some examples and the differences:

      Command in Bamboo Command Wrapped Command executed
      docker run --entrypoint="" image docker run --entrypoint=\"\" image docker run --entrypoint="" image
      docker run '--entrypoint=""' image docker run \'--entrypoint=""\' image docker run --entrypoint="" image
      docker run --entrypoint= image docker run --entrypoint= image docker run --entrypoint= image
      Command in Terminal Command executed (after evaluation)
      docker run --entrypoint="" image docker run --entrypoint= image
      docker run '--entrypoint=""' image docker run --entrypoint="" image
      docker run --entrypoint=\"\" image docker run --entrypoint="" image

      From the above you will see that:

      Bamboo command Equivalent in terminal client
      docker run --entrypoint="" image docker run --entrypoint=\"\" image
      docker run --entrypoint= image docker run --entrypoint="" image, OR docker run --entrypoint= image

            Assignee:
            Unassigned
            Reporter:
            Daniel Santos (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: