title: Running HashiCorp Vault in root-less docker container
body: <p>I'm trying to run Vault in container using root-less docker on Ubuntu 20.2. However, I keep getting the following error:</p>
  <pre><code>vault    | Error initializing core: Failed to lock memory: cannot allocate memory
  vault    |
  vault    | This usually means that the mlock syscall is not available.
  </code></pre>
  <p>The problem does not occur when running a container with docker having root privileges.</p>
  <p>Is there a way to provide root-less docker with privileges for mlock without disabling mlock and thus breaking vault security?</p>
  <p><code>docker-compose.yml</code>:</p>
  <pre class="lang-yaml prettyprint-override"><code>version: &quot;3&quot;
  services:
    vault:
      image: &quot;hashicorp/vault:1.8.0-rc2&quot;
      user: &quot;root&quot;
      container_name: vault
      restart: on-failure:10
      volumes:
        - ./config:/vault/config:rw
        - ./file:/vault/file:rw
      ports:
        - 8200:8200
      cap_add:
        - IPC_LOCK
      environment:
        - VAULT_ADDR=http://0.0.0.0:8200
      command: vault server -config=/vault/config
  </code></pre>
  <p><code>config.hcl</code>:</p>
  <pre><code>storage &quot;file&quot; {
    path    = &quot;/vault/file&quot;
  }
  
  listener &quot;tcp&quot; {
    address     = &quot;0.0.0.0:8200&quot;
    tls_disable = &quot;true&quot;
  }
  
  api_addr = &quot;http://127.0.0.1:8200&quot;
  ui = true
  </code></pre>