<p>I am to patch an image onto init containers</p>

<p>my image is stored in a variable called $IMAGE_NAME </p>

<p>When I run </p>

<blockquote>
  <p>kubectl patch deployment production-art-backend -p  {"spec":{"template":{"spec":{"initContainers":[{"name":"run-migrations","image":"$IMAGE_NAME"}]}}}}</p>
</blockquote>

<p>it patches the image as 'IMAGE_NAME' and not the value inside the variable IMAGE_NAME, how can I patch the image dynamically?</p>

cjmash
<p>This is a bash issue, not necessarily a <code>kubectl</code> issue!</p>

<p>Because the JSON string requires double quotes, you need to wrap the variable inside single quotes. Try this:</p>

<pre><code>kubectl patch deployment production-art-backend -p {"spec":{"template":{"spec":{"initContainers":[{"name":"run-migrations","image":"'${IMAGE_NAME}'"}]}}}}
</code></pre>
