Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • Guided learning
      Receive custom learning paths powered by our AI assistant.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Local Development Setup for Red Hat Mobile using Docker

June 14, 2017
Evan Shortiss
Related topics:
ContainersKubernetesMicroservices
Related products:
Red Hat build of Node.js

    Getting up and running with local development for Red Hat Mobile Application requires that you run MongoDB and Redis locally. Doing so isn’t particularly difficult if you follow online guides, but it would be much more straightforward if you could just get these pieces of software up and running in a single command and not need to worry about versioning, creating data directories, setting permissions, and compiling some things such as Redis from source. It would be even better if you could easily switch versions. This is where containers shine.

    In the next few paragraphs, we'll demonstrate how you can run any almost any version of MongoDB and Redis with a single command on a machine that has the Docker service installed.

    NOTE: This is not an extensive Docker CLI tutorial; just enough to learn basic commands that will allow you to get MongoDB and Redis up and running easily.

    Docker

    If you aren’t familiar with Docker then it’s worth heading over to their What is Docker? page, but to put it simply, the Docker project provides a container runtime that allows us to run software in a containerized environment. This means you can easily play around with a software package without affecting your host OS such as Ubuntu, Windows, or macOS. It also means you get preconfigured environments for running software which is exactly what we’d like for Redis and MongoDB - no complex setup required.

    Installing the Docker CLI is simple for Windows and macOS once you have a recent version of VirtualBox also installed on your machine. Ubuntu appears to be a little more involved, but the documentation is clear and concise so there should be no issues. Here are the guides for each platform:

    • Install Docker for Mac
    • Install Docker for Windows
    • Install Docker for Ubuntu

    Once you’ve finished following the guide for your system you can verify the installation by typing the following in a terminal:

    $ docker --version
    Docker version 17.03.0-ce, build 60ccb22
    

    If you see some version output then you’re good to go. It’s worth noting that I was initially running a much older version (1.11.0, build 4dc5990) and had encountered issues surrounding port mappings - so make sure you use a recent version!

    Running MongoDB in a Container

    The following command tells the Docker CLI to start a container that’s running Mongo db version 2.4.14. Passing the version is one of the most powerful features of the Docker CLI. Doing so allows us to test multiple versions of MongoDB in minutes without going through the arduous process of making configuration changes on our host machine! 2.4.14 is close to the version running on Red Hat Mobile Application Platform.

    docker run --name mongodb -p 27017:27017 -p 28017:28017 -d mongo:2.4.14

    You can use a tool such as Robomongo or mongo-express to connect and play around with the database. When developing node.js code you can use the mongodb module to connect.

    Being able to do this is extremely useful since if a MongoDB update is planned for your Red Hat Mobile deployment you can update to the same version for local development and test instantaneously.

    Running Redis in a Container

    Now that we appreciate the power of containers we can fire up Redis easily too. Just run the following command:

    docker run --name redis -p 6379:6379 -d redis

    If you want to verify it’s working you could use a tool such as redis-commander to access it, or just try from your application code using the node.js driver, or $fh.cache in the fh-mbaas-api.

    Executing Commands within a Container

    If you’d like to run commands inside a container (think like SSH’ing in) then you’ll need either the container ID or name. You can easily get the container name like using the docker ps command.

    Output from "docker ps"

    Once you have the ID, you can pass it to the exec command to get access to a bash prompt in the specified container:

    docker exec -it $CONTAINER_ID bash

    This is a neat way to debug your application’s interactions with the container, such as using SET, GET, and KEYS commands in our Redis container like so:

    $CONTAINER_ID=$(docker ps | grep -i redis | awk '{print $1}')
    $ docker exec -it $CONTAINER_ID bash
    
    root@8b0867a109fe:/data# redis-cli
    127.0.0.1:6379> keys *
    1) "cached-oauth-token"
    127.0.0.1:6379> exit
    root@8b0867a109fe:/data# exit

    Docker Containerized Environment Performance vs. Native

    When running a containerized application on macOS or Windows for development purposes you need to run it within VirtualBox since these systems don’t have kernel level container support like Linux does. Ultimately we should not worry about this since our goal with this post is to use containers on our development machines where high performance isn’t a concern, but for the curious the differences I noted between a native MongoDB instance vs. one running in the docker-formatted container are:

    • Containerized MongoDB 1,000 Sequential Insert Time: ~775ms
    • Containerized MongoDB 1,000 Concurrent Insert Time: ~429ms
    • Native MongoDB macOS 1,000 Sequential Insert Time: ~422ms
    • Native MongoDB macOS 1,000 Concurrent Insert Time: ~311ms

    Or if you prefer graphs here it is:

    Docker Performance Comparison

    Both are using node.js 4.4.3, MongoDB v2.4.14, no indexes applied, and just a default empty collection. The MacBook Pro performing the test is a 2.5GHz Intel Core i7 with 16GB 1600MHz RAM and a 500GB SSD (mid-2015 model).

    The code for each test is linked below:

    • mongo-concurrent-insert-perf.js
    • mongo-sequential-insert-perf.js

    I’m perfectly happy with the numbers posted by the MongoDB instance running in a docker-formatted container since, typically as developers, we’re not doing much benchmarking on our own machines so the difference will be negligible unless you’re dealing with huge numbers of queries and extremely large payloads.


    There are many GUI tools to connect to MongoDB databases and browse, download this cheat sheet to get to the command line to get the command line you need.

    Last updated: October 31, 2023

    Recent Posts

    • Red Hat Hardened Images: Top 5 benefits for software developers

    • How EvalHub manages two-layer Kubernetes control planes

    • Tekton joins the CNCF as an incubating project

    • Federated identity across the hybrid cloud using zero trust workload identity manager

    • Confidential virtual machine storage attack scenarios

    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Build

    • Developer Sandbox
    • Developer tools
    • Interactive tutorials
    • API catalog

    Quicklinks

    • Learning resources
    • E-books
    • Cheat sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site status dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit
    © 2026 Red Hat

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Chat Support

    Please log in with your Red Hat account to access chat support.