title: Executing a shell script having docker | docker commands not found
body: <p>I created a pipeline in Azure with Ubuntu 18.04. My requirement was to run a docker image using bash script and for the same below script was created but on execution I received an error "docker command does not exist and docker: invalid reference format. </p>
  
  <blockquote>
    <p>test.sh</p>
  </blockquote>
  
  <pre><code>#!/bin/bash
  #
  echo "=== docker Images==="
  docker images
  echo "==== Starut running a jmeter/image ===="
  docker run "justb4/jmeter:latest"
  echo "==== Finish ===="
  </code></pre>
  
  <blockquote>
    <p>Error</p>
  </blockquote>
  
  <pre><code>Starting: Bash Script scripts/test.sh
  ==============================================================================
  Task         : Bash
  Description  : Run a Bash script on macOS, Linux, or Windows
  Version      : 3.163.2
  Author       : Microsoft Corporation
  Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/utility/bash
  ==============================================================================
  Generating script.
  Formatted command: bash '/home/vsts/work/1/s/scripts/test.sh' 'justb4/jmeter:latest' mainTest.jmx qa-url 30 1 60 15 2 60 1000
  ========================== Starting Command Output ===========================
  /bin/bash --noprofile --norc /home/vsts/work/_temp/5c641c31-4e55-4ab8-be9e-4cf850432bab.sh
  === docker Images===
  docker: 'images
  ' is not a docker command.
  See 'docker --help'
  ==== Starut running a jmeter/image ====
  docker: invalid reference format.
  See 'docker run --help'.
  ==== Finish ====
  
  Finishing: Bash Script scripts/test.sh
  </code></pre>
  
  <p><strong>To describe in detail, here are the tasks created on az pipeline :-</strong></p>
  
  <pre><code>1. Install a docker
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Z74oz.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z74oz.jpg" alt="enter image description here"></a> </p>
  
  <pre><code>Output of Task1
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/ja8R7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ja8R7.jpg" alt="enter image description here"></a></p>
  
  <pre><code>2. Just for debugging purpose, I added below bash task **with inline commands** to see if docker 
  </code></pre>
  
  <p>commands work and it worked perfectly fine with no issues. But in task3, when I tried to execute the 
  scripts with the same commands it failed.</p>
  
  <p><a href="https://i.stack.imgur.com/e3193.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e3193.jpg" alt="enter image description here"></a></p>
  
  <p>Output of Task2</p>
  
  <p><a href="https://i.stack.imgur.com/bR0pV.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bR0pV.jpg" alt="enter image description here"></a></p>
  
  <pre><code>3. Task 3 to execute test.sh script having docker commands
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/w92Ya.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w92Ya.jpg" alt="enter image description here"></a></p>
  
  <p>Output of Task3
  <a href="https://i.stack.imgur.com/mMHVv.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mMHVv.jpg" alt="enter image description here"></a></p>