title: How to start a Docker container with cloud-config file for CoreOS?
body: <p>I'm trying to configure my CoreOS server with Terraform, using <a href="https://coreos.com/os/docs/latest/cloud-config.html" rel="nofollow">cloud-config file for  CoreOS</a>. I am currently trying to set up a Mongo database in a <em>Docker</em> container.
  Here is my config file:</p>
  
  <pre><code>write_files:
    - path: "/home/core/keyfile"
    permissions: "0600"
    owner: "999"
    content: |
      hUoQVrERB0*** &lt;here is my key for MongoDB&gt;
  
  coreos:
    units:
      - name: "dockerstart.service"
        command: "start"
        content: |
          [Unit]
          Description=Start
          Author=Me
  
          [Service]
          Restart=always
          ExecStart=/usr/bin/docker run --name mongo -v /home/core:/opt --add-host node1.example.com:127.0.0.1 -p 27017:27017 -d mongo:2.6.5 --smallfiles --keyFile /opt/keyfile --replSet "rs0"
          ExecStop=/usr/bin/docker rm -f mongo
  </code></pre>
  
  <p>I am not sure how to use coreOS <code>units</code> (when I ssh into the server, the docker container is not running, so the config file is not correct). According to <a href="https://coreos.com/validate/" rel="nofollow">CoreOS Validator</a>, my file is valid. Also, I am not sure if that is the simplest way to deploy a MongoDB server.
  <strong>How to properly use CoreOS <code>units</code> ? Any thoughts on a way to improve how deploy a Mongo Database ?</strong> </p>
  
  <p>Any help, comments, suggestions are appreciated !</p>