title: Insertafter or replace '[' in docker daemon.json using sed or ansible
body: <p>File name: docker daemon.json
  location: /etc/docker/daemon.json
  content:</p>
  <pre><code>{
      &quot;insecure-registries&quot;: [
          &quot;registry1.com:5001&quot;,
          &quot;registry2.com&quot;
      ],
      &quot;storage-driver&quot;: &quot;overlay2&quot;
  }
  </code></pre>
  <p>Want to make the above content like this</p>
  <pre><code>{
      &quot;insecure-registries&quot;: [
          &quot;registry0.com:5000&quot;,
          &quot;registry1.com:5001&quot;,
          &quot;registry2.com&quot;
      ],
      &quot;storage-driver&quot;: &quot;overlay2&quot;
  }
  </code></pre>
  <p>OR</p>
  <pre><code>{
      &quot;insecure-registries&quot;: [&quot;registry0.com:5000&quot;,
          &quot;registry1.com:5001&quot;,
          &quot;registry2.com&quot;
      ],
      &quot;storage-driver&quot;: &quot;overlay2&quot;
  }
  </code></pre>
  <p>Tried sed to replace <code>[</code> with <code>[&quot;registry0.com:5000&quot;,</code> but no go.
  We are using ansible and unfortunately none of their modules like <code>insertafter</code> <code>lineinfile</code> have been fruitful so far. Either ansible way or bash way of doing it is fine. Appreciate the help.</p>