title: How can I install docker on a VM using devcontainer.json?
body: <p>I want to automate the installation of docker and docker-compose on a newly created VM. Ideally this should be done from the <em>devcontainer.json</em> file such that if a developer opens the project the Debian/Ubuntu packages <em>docker.io</em> and <em>docker-compose</em> are installed automatically.</p>
  <p>I tried adding</p>
  <pre class="lang-json prettyprint-override"><code>&quot;initializeCommand&quot;: &quot;sudo apt update &amp;&amp; sudo apt upgrade -y &amp;&amp; sudo apt install -y docker.io docker-compose&quot;,
  </code></pre>
  <p>to the main hirarchy of <em>devcontainer.json</em> but it will not run before VS Code starts creating the container. VS Code gives an error message that Docker is not installed, although the <code>initializeCommand</code> command is supposed to be run before the container setup.</p>
  <p>Is there any other way of achieving this except using additional tools or e.g. Azure VM templates?</p>