Skip to content

docker-run-local is a lightweight Docker-based local development environment that helps you spin up essential backend services like PostgreSQL, MongoDB, and more — with zero manual setup.

Notifications You must be signed in to change notification settings

akashdeep023/docker-run-local

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Docker Run Local

  • docker-run-local is a lightweight Docker-based local development environment that helps you spin up essential backend services like PostgreSQL, MongoDB, and more — with zero manual setup.

Using docker to run packages locally.

Installing Docker

  • Docker GUI is the easiest way to get off the ground.

  • You can find instructions to install docker on Installing Docker

  • At the end of the installation, you need to make sure you’re able to run the following command -

    docker run hello-world
    

What are we using docker for?

  • Docker let’s you do a lot of things.

  • It let’s you containerise your applications.

  • It let’s you run other people’s code + packages in your machine.

  • It let’s you run common software packages inside a container (For eg - Mongo, Postgres etc)

        Window/Mac Machine
         ____________________________________________________
        |                                                    |
        |                                                    |
        |       Container               Container            |
        |       ______________        ______________         |
        |      |              |      |              |        |
        |      |   MongoDB    |      |  Postgres    |        |
        |      |              |      |              |        |
        |      |    27017     |      |    5432      |        |
        |      |______________|      |______________|        |
        |                                                    |
        |____________________________________________________|
    

Where can we get packages from?

  • Just like you can push your code to Github/Gitlab.
  • You can push images to docker registries

Common commands to know

1. Running an image

  • Let’s say you wan’t to run MongoDB locally Docker MongoDB

    docker run mongo
  • You will notice you can’t open it in MongoDB Compass

2. Adding a port mapping

  • The reason is that you haven’t added a port mapping

    # docker run -p <local_port>:<container_port> mongo
    docker run -p 27017:27017 mongo

3. Running a detached container

  • The -d flag will run the container in the background

  • This will allow you to run the container and continue using the terminal for other commands.

    docker run -d -p 27017:27017 mongo

4. Inspecting a container

  • This will show you all the containers you are running.

    docker ps

5. Stopping a container

  • Will stop the container that you are running

    docker kill <container_id>

Common packages

Mongo

docker run -d -p 27017:27017 mongo
  • The connection string for this mongo would be

    mongodb://localhost:27017

Postgres

docker run -e POSTGRES_PASSWORD=mysecretpassword -d -p 5432:5432 postgres
  • The connection string for this postgres would be

    postgresql://postgres:mysecretpassword@localhost:5432/postgres

About

docker-run-local is a lightweight Docker-based local development environment that helps you spin up essential backend services like PostgreSQL, MongoDB, and more — with zero manual setup.

Topics

Resources

Stars

Watchers

Forks