Skip to content

Latest commit

 

History

History
88 lines (60 loc) · 1.81 KB

README.md

File metadata and controls

88 lines (60 loc) · 1.81 KB

Simple Docker Examples

My Docker playground examples, written for learning purposes.
Tested on MacOS, so feel free to open a PR if you are using another platform.
Warning: may not be suitable for production use.

What's in the box

Currently, each example uses nodemon for:

  1. Debugging
  2. Watching files and live-reload the app

Usage

  1. Install Docker.

  2. Clone this repository:

    git clone https://github.com/eranshmil/docker-examples.git
  3. Go to the folder you want to use, for example:

    cd express-mongo
  4. Run the following command to create the containers:

     docker-compose up
  5. When you finish developing, run:

    docker-compose down
  • If you have some issue, try to run the container with the build flag:

    docker-compose up --build

Standalone services

Running only one service in the container:

docker-compose run --service-ports mongo
  • In this example, the service called mongo
  • The service-ports flag publishes the service ports to the host machine

Breakpoint at first line

In order to debug the initialization process of your app, change the --inspect flag to --inspect-brk in the relevant package.json.
For example:

{
    ...
    "scripts": {
        ...
        "watch": "nodemon -L --inspect-brk=0.0.0.0"
    }
    ...
}

Debugging with vscode

Todo

  1. Add documentation about parameters used in Dockerfile and docker-compose.yml.
  2. Explain about the first example.
  3. Examples to add:
    • Angular container
    • Laravel container

Resources

  1. Official NodeJS Debugging Guide