Skip to content

Instantly share code, notes, and snippets.

@aaronksaunders
Last active September 16, 2021 03:01
Show Gist options
  • Select an option

  • Save aaronksaunders/06b1808e95440e32ed74e7d38161a86d to your computer and use it in GitHub Desktop.

Select an option

Save aaronksaunders/06b1808e95440e32ed74e7d38161a86d to your computer and use it in GitHub Desktop.

Revisions

  1. aaronksaunders revised this gist Sep 16, 2021. No changes.
  2. aaronksaunders revised this gist Sep 16, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion readme.md
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,2 @@
    #Docker With Mongo
    # Docker With Mongo
    My helper for creating a docker container running mongo where i set the super and then create a user. I also want the data to persist so i have added a volume
  3. aaronksaunders created this gist Sep 16, 2021.
    16 changes: 16 additions & 0 deletions docker-compose.yml
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    version: '3'

    services:
    mongodb:
    image: mongo:4.2
    environment:
    MONGO_INITDB_ROOT_USERNAME: aks_root
    MONGO_INITDB_ROOT_PASSWORD: aks_root
    ports:
    - '27017:27017'
    volumes:
    - db_data:/data/db
    - ./mongo-init.js:/docker-entrypoint-initdb.d/mongo-init.js:ro

    volumes:
    db_data:
    14 changes: 14 additions & 0 deletions mongo-init.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    conn = new Mongo();
    db = conn.getDB("test-database");
    db.createUser(
    {
    user: "test-user",
    pwd: "test-password",
    roles: [
    {
    role: "dbOwner",
    db: "test-database"
    }
    ]
    }
    );
    2 changes: 2 additions & 0 deletions readme.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    #Docker With Mongo
    My helper for creating a docker container running mongo where i set the super and then create a user. I also want the data to persist so i have added a volume