### Example Production Node-RED Docker Setup Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/quick-reference.md A comprehensive example of running Node-RED in a production environment using Docker. It includes port mapping, persistent storage, resource limits, and timezone configuration. ```bash docker run -d \ -p 1880:1880 \ --name node-red \ --restart unless-stopped \ --cpus 2 \ --memory 1g \ -e NODE_OPTIONS="--max_old_space_size=768" \ -e TZ=UTC \ -v ~/node-red/data:/data \ nodered/node-red:4.1.10-20 ``` -------------------------------- ### Custom Dockerfile Build Example Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/installation-scripts.md This example shows how to customize a Node-RED Docker build by overriding scripts and installing additional packages. It uses a multi-stage build approach. ```dockerfile FROM nodered/node-red # Override scripts COPY custom-install-devtools.sh /tmp/install_devtools.sh # Install additional packages RUN /tmp/install_devtools.sh ``` -------------------------------- ### Real-World Example: Full Node-RED Docker Configuration Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/entrypoint.md Demonstrates a comprehensive setup for running Node-RED in production, including persistent storage, custom flows, heap limits, safe mode, and graceful shutdown. ```bash # Start Node-RED with 2GB heap, custom flows file, and safe mode docker run -d \ -p 1880:1880 \ -v node_red_data:/data \ -e NODE_OPTIONS="--max_old_space_size=2048" \ -e FLOWS=production_flows.json \ -e NODE_RED_ENABLE_SAFE_MODE=true \ --name prod-red \ nodered/node-red # Monitor startup docker logs -f prod-red # Stop gracefully (sends SIGTERM, waits 10 seconds) docker stop prod-red # Force kill if hung (sends SIGKILL immediately) docker kill prod-red ``` -------------------------------- ### Run Node-RED with Devtools Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/installation-scripts.md Example command to run the Node-RED Docker container with development tools installed, enabling the installation of nodes with native dependencies. ```bash docker run -it -p 1880:1880 nodered/node-red:latest ``` -------------------------------- ### Node-RED Manifest List Contents Example Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/image-tags.md This example shows the structure of a manifest list for a specific version, detailing the images available for different architectures. ```bash MANIFEST: nodered/node-red:4.1.10-20 ├── nodered/node-red:4.1.10-20-amd64 (AMD/Intel 64-bit) ├── nodered/node-red:4.1.10-20-arm32v6 (Raspberry Pi Zero) ├── nodered/node-red:4.1.10-20-arm32v7 (Raspberry Pi 2/3) ├── nodered/node-red:4.1.10-20-arm64v8 (Raspberry Pi 4) ├── nodered/node-red:4.1.10-20-s390x (IBM System z) └── nodered/node-red:4.1.10-20-i386 (32-bit x86) MANIFEST: nodered/node-red:4.1.10 Same as above (Node.js 20 is implicit default) MANIFEST: nodered/node-red:latest Points to nodered/node-red:4.1.10 ``` -------------------------------- ### Install Recommended GPIO Node Replacement Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/installation-scripts.md Command to install the recommended `node-red-node-pi-gpiod` package, which is compatible with containerized Node-RED. ```bash npm install node-red-node-pi-gpiod ``` -------------------------------- ### Install Node-RED Admin Tool and Node Source: https://github.com/node-red/node-red-docker/blob/master/README.md Installs the Node-RED admin tool globally on the host and then uses it to install a specific Node-RED node. Assumes Node-RED is accessible at http://localhost:1880. ```bash $ npm install -g node-red-admin $ node-red-admin install node-red-node-openwhisk ``` -------------------------------- ### Enable Verbose Logging for Node-RED Startup Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/README.md Start the Node-RED process with verbose logging enabled to get more detailed output during startup. This can be helpful for debugging. ```bash docker exec -it mynodered npm start -- --verbose ``` -------------------------------- ### Example package.json for Node-RED Project Source: https://github.com/node-red/node-red-docker/wiki/Quick-Custom-Image This package.json defines Node-RED and its dependencies, along with a script to start the Node-RED runtime. It's required when building a custom Docker image. ```json { "name": "node-red-project", "description": "A Node-RED Project", "version": "0.0.1", "dependencies": { "node-red": "1.0.2", "node-red-contrib-web-worldmap": "*", "node-red-dashboard": "*" }, "scripts": { "start": "node $NODE_OPTIONS node_modules/node-red/red.js $FLOWS" } } ``` -------------------------------- ### Install Development Tools (install_devtools.sh) Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/installation-scripts.md Conditionally installs build tools and libraries for native module compilation. Skips installation if the TAG_SUFFIX environment variable contains 'minimal'. ```bash #!/bin/bash set -ex # Installing Devtools if [[ ${TAG_SUFFIX} != *"minimal"* ]]; then echo "Installing devtools" apk add --no-cache --virtual devtools build-base linux-headers udev python3 else echo "Skip installing devtools" fi ``` -------------------------------- ### Example Architecture-Specific Tags Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/image-tags.md These examples demonstrate how to pull specific architecture-specific Docker images. This is generally not recommended as manifest lists are preferred for automatic architecture selection. ```bash # Pull specific architecture (not recommended) docker pull nodered/node-red:4.1.10-20-arm32v7 ``` ```bash # Explicit minimal variant docker pull nodered/node-red:4.1.10-20-minimal-amd64 ``` ```bash # Old Debian variant docker pull nodered/node-red:4.1.10-20-debian-amd64 ``` -------------------------------- ### Basic Node-RED Container Startup Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/quick-reference.md Starts a Node-RED container with default settings, mapping port 1880 and using a named volume for data persistence. ```bash docker run -it -p 1880:1880 -v node_red_data:/data --name mynodered nodered/node-red ``` -------------------------------- ### Setup Dependencies Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/build-system.md Updates Docker Community Edition to the latest version using apt. Requires sudo access. ```bash function setup_dependencies() { sudo apt update -y sudo apt install --only-upgrade docker-ce -y } ``` -------------------------------- ### Manifest Annotations Example Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/image-tags.md Illustrates the annotations associated with an image within a manifest list, which Docker uses for automatic platform selection. ```bash Image: nodered/node-red:4.1.10-20-arm32v7 Annotations: OS: linux Arch: arm Variant: v7 ``` -------------------------------- ### Node-RED Container Startup with Minimal Variant Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/quick-reference.md Starts a Node-RED container using the 'latest-minimal' image, which is a smaller variant. ```bash docker run -it -p 1880:1880 -v node_red_data:/data --name mynodered nodered/node-red:latest-minimal ``` -------------------------------- ### Prepare Build Environment Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/build-system.md Use the 'prepare' command to set up the build environment, including installing dependencies and configuring QEMU for multi-architecture builds. This command requires the QEMU_VERSION environment variable to be set. ```bash ./.docker/docker.sh prepare ``` -------------------------------- ### Node-RED Docker Container Startup Logs Source: https://github.com/node-red/node-red-docker/wiki/Home Example output from a Node-RED Docker container upon startup, showing version information, settings, and server status. ```text Welcome to Node-RED =================== 10 Aug 12:57:10 - [info] Node-RED version: v1.0 10 Aug 12:57:10 - [info] Node.js version: v10.16.2 10 Aug 12:57:10 - [info] Linux 4.19.58-v7+ arm LE 10 Aug 12:57:11 - [info] Loading palette nodes 10 Aug 12:57:16 - [info] Settings file : /data/settings.js 10 Aug 12:57:16 - [info] Context store : 'default' [module=memory] 10 Aug 12:57:16 - [info] User directory : /data 10 Aug 12:57:16 - [warn] Projects disabled : editorTheme.projects.enabled=false 10 Aug 12:57:16 - [info] Flows file : /data/flows.json 10 Aug 12:57:16 - [info] Creating new flow file 10 Aug 12:57:17 - [warn] --------------------------------------------------------------------- Your flow credentials file is encrypted using a system-generated key. If the system-generated key is lost for any reason, your credentials file will not be recoverable, you will have to delete it and re-enter your credentials. You should set your own key using the 'credentialSecret' option in your settings file. Node-RED will then re-encrypt your credentials file using your chosen key the next time you deploy a change. --------------------------------------------------------------------- 10 Aug 12:57:17 - [info] Server now running at http://127.0.0.1:1880/ [...] ``` -------------------------------- ### Install Additional Nodes in Running Container Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/README.md Use this command to install new Node-RED nodes directly into a running container. You must stop and start the container for changes to take effect. ```bash docker exec -it mynodered npm install node-red-node-smooth docker stop mynodered docker start mynodered ``` -------------------------------- ### Node-RED Docker Alias Usage Examples Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/quick-reference.md Examples demonstrating how to use the defined Node-RED Docker management aliases for common tasks like following logs, executing commands, and restarting containers. ```bash nrl # Follow logs nre npm list # List packages nrs # Restart nrrm # Remove container nrpull # Pull latest image ``` -------------------------------- ### Tag Selection for Specific Architectures Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/image-tags.md Examples for pulling Node-RED images tailored for specific architectures like Raspberry Pi (ARM) or IBM System z (s390x). All examples use manifest lists for automatic architecture selection. ```bash # Raspberry Pi 3B+ (ARM v7) docker pull nodered/node-red:latest-20 # Raspberry Pi 4 (ARM v8) docker pull nodered/node-red:latest-20 # Intel/AMD server (amd64) docker pull nodered/node-red:latest-20 # s390x (IBM System z) docker pull nodered/node-red:latest-20 ``` -------------------------------- ### Node-RED Container Startup with Custom Flows File Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/quick-reference.md Starts a Node-RED container, specifying a custom flows file to be loaded. ```bash docker run -it -p 1880:1880 -v node_red_data:/data -e FLOWS=custom_flows.json --name mynodered nodered/node-red ``` -------------------------------- ### Run Node-RED Minimal (No Devtools) Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/installation-scripts.md Example command to run the Node-RED Docker container with the minimal image, which does not include development tools and cannot compile native modules. ```bash docker run -it -p 1880:1880 nodered/node-red:latest-minimal ``` -------------------------------- ### Stop, Start, and Restart Node-RED Container Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/quick-reference.md Commands for managing the lifecycle of a Node-RED container, including graceful stopping, starting, and restarting. ```bash docker stop mynodered # Graceful stop (10 seconds) docker stop --time=30 mynodered # Custom timeout docker start mynodered # Start stopped container docker restart mynodered # Restart container ``` -------------------------------- ### Start Docker Compose Services Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/quick-reference.md Starts the services defined in a Docker Compose file in detached mode. ```bash docker-compose up -d ``` -------------------------------- ### Run Custom Docker Image Source: https://github.com/node-red/node-red-docker/wiki/Building-Custom-Image Start a container from the newly built custom Docker image, mapping port 1880 for Node-RED access. ```shell docker run -it -p1880:1880 testing:node-red-build ``` -------------------------------- ### Start Node-RED in Debug Mode with Break on First Statement Source: https://github.com/node-red/node-red-docker/blob/master/README.md Use this command to start Node.js in debug mode and break at the very first statement of the Node-RED application. This is useful for debugging startup code. Node.js will wait for a debugger client to connect. ```bash docker run -it -p 1880:1880 -p 9229:9229 -v node_red_data:/data --name mynodered --entrypoint npm nodered/node-red run debug_brk -- --userDir /data ``` -------------------------------- ### Travis CI 'install' Hook Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/ci-pipeline.md Skips the default dependency installation process in Travis CI, as Docker is used to manage all build dependencies. ```yaml install: true ``` -------------------------------- ### Node-RED Container Startup with Custom Timezone Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/quick-reference.md Starts a Node-RED container, setting a custom timezone for the container's environment. ```bash docker run -it -p 1880:1880 -v node_red_data:/data -e TZ=America/New_York --name mynodered nodered/node-red ``` -------------------------------- ### Test Docker Image Startup Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/build-system.md The 'test' command verifies that the built Docker image can start successfully. It requires the TARGET environment variable to be set with the image name. This command runs a temporary container and exits without keeping it. ```bash ./.docker/docker.sh test ``` ```bash docker run -d --rm --name=testing ${TARGET}:build ``` -------------------------------- ### Docker Compose Basic Setup Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/image-tags.md A basic Docker Compose configuration to set up a Node-RED service, mapping the default port and mounting a local directory for data persistence. ```yaml services: node-red: image: nodered/node-red:latest ports: - "1880:1880" volumes: - ~/node-red/data:/data ``` -------------------------------- ### Test Docker Image Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/ci-pipeline.md Verifies that the built Docker image can successfully start a container. This is a crucial step to ensure image integrity before further processing. ```bash ./.docker/docker.sh test ``` -------------------------------- ### Run Custom Node-RED Docker Image Source: https://github.com/node-red/node-red-docker/blob/master/docker-custom/README.md Start a container from the built custom Node-RED Docker image, mapping the Node-RED port and mounting a volume for data persistence. ```shell $ docker run -it -p1880:1880 -v node_red_data:/data --name myNRtest testing:node-red-build ``` -------------------------------- ### Docker Stop Command Example Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/entrypoint.md Demonstrates how to stop a running Node-RED container using the 'docker stop' command, which triggers the graceful shutdown sequence. ```bash docker stop mynodered ``` -------------------------------- ### Run Installation Script Manually in Container Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/installation-scripts.md This command allows you to run installation scripts manually within a Node-RED Docker container. It shows the first 20 lines of output from the install_devtools.sh script. ```bash docker run -it --entrypoint /bin/sh nodered/node-red # Inside container bash -x /tmp/install_devtools.sh 2>&1 | head -20 ``` -------------------------------- ### Node-RED Container Startup with Increased Heap Size Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/quick-reference.md Starts a Node-RED container with an increased maximum old space size for the Node.js heap. ```bash docker run -it -p 1880:1880 -v node_red_data:/data -e NODE_OPTIONS="--max_old_space_size=1024" --name mynodered nodered/node-red ``` -------------------------------- ### Install Node within Container Shell Source: https://github.com/node-red/node-red-docker/blob/master/README.md Accesses the command line inside a running Node-RED container, navigates to the data directory, installs a Node-RED node, and then exits. The container is stopped and restarted to apply changes. ```bash $ cd /data $ npm install node-red-node-smooth $ exit $ docker stop mynodered $ docker start mynodered ``` -------------------------------- ### Build Custom Node-RED Docker Image Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/quick-reference.md A Dockerfile example for building a custom Node-RED Docker image, typically used for adding custom nodes or configurations. ```dockerfile # Dockerfile content would go here ``` -------------------------------- ### Interactive Mode: Ctrl-C Example Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/entrypoint.md Illustrates the sequence of events when a user presses Ctrl-C in an interactive Docker session, leading to a SIGINT signal being sent to the entrypoint script. ```bash docker run -it ... nodered/node-red ``` -------------------------------- ### Node-RED Settings Example (HTTP Mode) Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/healthcheck.md This JavaScript snippet shows the basic configuration for Node-RED's settings file when running in HTTP mode. It specifies the UI port. ```javascript // /data/settings.js - for HTTP mode (default) module.exports = { uiPort: 1880, // ... other settings }; ``` -------------------------------- ### Install Additional Nodes by Building Custom Image Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/README.md Build a custom Docker image with additional Node-RED nodes pre-installed. This is useful for creating standardized Node-RED environments. ```dockerfile FROM nodered/node-red RUN npm install node-red-node-smooth ``` -------------------------------- ### Entrypoint Script Content Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/entrypoint.md The main entrypoint script for the Node-RED Docker container. It sets up signal handling and starts the Node-RED process in the background. ```bash #!/bin/bash trap stop SIGINT SIGTERM function stop() { kill $CHILD_PID wait $CHILD_PID } /usr/local/bin/node $NODE_OPTIONS node_modules/node-red/red.js --userDir /data $FLOWS "${@}" & CHILD_PID="$!" wait "${CHILD_PID}" ``` -------------------------------- ### Run Node-RED with Node.js Options Source: https://github.com/node-red/node-red-docker/blob/master/README.md Starts Node-RED in a Docker container, passing Node.js runtime arguments via the NODE_OPTIONS environment variable to configure garbage collection heap size. Mounts a volume for data persistence. ```bash docker run -it -p 1880:1880 -e NODE_OPTIONS="--max_old_space_size=128" -v node_red_data:/data nodered/node-red ``` -------------------------------- ### Travis CI 'before_script' Hook - Target and Version Setup Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/ci-pipeline.md Sets the target Docker repository based on whether a Git tag is present and extracts the Node-RED version from package.json. Also determines the build version from the Git tag. ```bash before_script: # Set TARGET Docker Repo - > export TARGET=nodered/node-red-dev if [[ "${TRAVIS_TAG}" =~ ^v[0-9\.-]*$ ]]; then export TARGET=nodered/node-red fi # Set NODE_RED_VERSION from package.json - > export NODE_RED_VERSION=$(grep -oE "\"node-red\": \"(\w*.\w*.\w*.\w*.\w*.)" package.json | cut -d\" -f4) # Set BUILD_VERSION - > if [ ! -z "${TRAVIS_TAG}" ]; then export BUILD_VERSION=${TRAVIS_TAG:1}; fi ``` -------------------------------- ### Node-RED Settings Example (HTTPS Mode) Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/healthcheck.md This JavaScript snippet demonstrates the configuration for Node-RED's settings file when running in HTTPS mode. It includes HTTPS certificate details. ```javascript // /data/settings.js - for HTTPS mode module.exports = { uiPort: 1880, https: { key: require("fs").readFileSync('privatekey.pem'), cert: require("fs").readFileSync('certificate.pem') }, // ... other settings }; ``` -------------------------------- ### Run Node-RED in Safe Mode Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/entrypoint.md Starts Node-RED without automatically starting flows, useful for debugging or initial setup. Enabled via the NODE_RED_ENABLE_SAFE_MODE environment variable. ```bash docker run -e NODE_RED_ENABLE_SAFE_MODE=true ... ``` -------------------------------- ### Run Node-RED with Custom Flows File Source: https://github.com/node-red/node-red-docker/blob/master/README.md Starts Node-RED in a Docker container, specifying a custom flows configuration file using the FLOWS environment variable. Mounts a volume for data persistence. ```bash docker run -it -p 1880:1880 -e FLOWS=my_flows.json -v node_red_data:/data nodered/node-red ``` -------------------------------- ### Travis CI 'before_install' Hook Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/ci-pipeline.md Executes a script to prepare the build environment by updating dependencies, enabling Docker experimental features, and configuring QEMU for cross-architecture builds. ```bash before_install: - ./.docker/docker.sh prepare ``` -------------------------------- ### Debug Container Startup Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/README.md Run a Node-RED container in debug mode, exposing the Node.js debug port and using npm to start Node-RED with debugging enabled. This is useful for troubleshooting startup issues. ```bash docker run -it \ -p 1880:1880 \ -p 9229:9229 \ -v node_red_data:/data \ --entrypoint npm \ nodered/node-red \ run debug -- --userDir /data ``` -------------------------------- ### Run Node-RED Headless Source: https://github.com/node-red/node-red-docker/blob/master/README.md Starts Node-RED in detached mode in a Docker container, forwarding port 1880. This is a minimal setup without persistent volume mounting. ```bash $ docker run -d -p 1880:1880 nodered/node-red ``` -------------------------------- ### Dockerfile for Custom Node-RED Image Source: https://github.com/node-red/node-red-docker/wiki/Quick-Custom-Image Use this Dockerfile to copy project files and install custom Node-RED modules into a Docker image. Ensure your package.json includes Node-RED as a dependency and has a start script. ```docker FROM nodered/node-red # copy node-red project files into place COPY flows.json /data/flows.json COPY flows_cred.json /data/flows_cred.json COPY settings.js /data/settings.js # copy package.json to the WORKDIR so npm builds for node-red COPY package.json . RUN npm install --unsafe-perm --no-update-notifier --no-audit --only=production CMD ["npm", "start"] ``` -------------------------------- ### Run MQTT Broker Container Source: https://github.com/node-red/node-red-docker/blob/master/README.md Launches an MQTT broker container named 'mybroker' and connects it to the 'iot' network. The broker is configured to use a specific configuration file. ```bash docker run -itd --network iot --name mybroker eclipse-mosquitto mosquitto -c /mosquitto-no-auth.conf ``` -------------------------------- ### Install Development Packages (Alpine Linux) Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/installation-scripts.md Specifies the packages installed by `install_devtools.sh` when devtools are enabled. These are essential for compiling native Node.js modules. ```bash apk add --no-cache --virtual devtools build-base linux-headers udev python3 ``` -------------------------------- ### Node-RED package.json Dependencies Source: https://github.com/node-red/node-red-docker/blob/master/README.md The package.json file in a Node-RED Docker build specifies the Node-RED version and any additional npm packages to be installed. Dependencies are installed under /usr/src/node-red. ```json "dependencies": { "node-red": "^4.1.10", <-- set the version of Node-RED here "node-red-dashboard": "*" <-- add any extra npm packages here }, "scripts" : { "start": "node-red -v $FLOWS" }, ``` -------------------------------- ### Check Installed npm Packages Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/quick-reference.md List installed npm packages within the Node-RED container. You can view all packages, filter by name, or check for a specific package. ```bash docker exec mynodered npm list # All packages docker exec mynodered npm list | grep red # Filter docker exec mynodered npm list node-red # Specific package ``` -------------------------------- ### Check Installed Packages in Node-RED Containers Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/installation-scripts.md Use these commands to list installed packages and filter for build and python-related packages in both default and minimal Node-RED Docker images. ```bash docker run -it nodered/node-red:latest apk list | grep -E "build|python" ``` ```bash docker run -it nodered/node-red:latest-minimal apk list | grep -E "build|python" ``` -------------------------------- ### Architecture Mappings for Multi-Platform Builds Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/types.md Maps target CPU architectures to QEMU architectures for creating multi-platform Docker images. This ensures compatibility across different hardware. ```bash amd64 -> x86_64 (64-bit Intel/AMD) arm32v6 -> arm (32-bit ARM v6, Raspberry Pi Zero) arm32v7 -> arm (32-bit ARM v7, Raspberry Pi 2/3) arm64v8 -> aarch64 (64-bit ARM v8, Raspberry Pi 4) s390x -> s390x (IBM System z) i386 -> i386 (32-bit x86 Intel) ``` -------------------------------- ### Node.js Debugger Listening Message Source: https://github.com/node-red/node-red-docker/wiki/Debug-container-via-Chrome-Developer-Tools This message indicates that the Node.js server has started and is listening on the specified WebSocket port for debugger clients. It is displayed in the server logs when Node-RED is started in debug mode. ```text Debugger listening on ws://0.0.0.0:9229/... ``` -------------------------------- ### Create Manifest List Beta Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/build-system.md Creates a manifest list tagged as 'beta' for pre-release versions. Use for beta testing. ```bash ./.docker/docker.sh manifest_list_beta "20" "default" ``` -------------------------------- ### Prepare QEMU for Cross-Architecture Docker Builds Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/build-system.md This function configures QEMU for cross-architecture Docker image building. It requires the QEMU_VERSION environment variable to be set and the Docker daemon to be running with privileged access. It downloads and extracts QEMU binaries for various architectures and registers them with the Docker daemon. ```bash function prepare_qemu() { docker run --rm --privileged multiarch/qemu-user-static:register --reset mkdir tmp && cd tmp curl -L -o qemu-x86_64-static.tar.gz https://github.com/.../qemu-x86_64-static.tar.gz && tar xzf ... curl -L -o qemu-arm-static.tar.gz https://github.com/.../qemu-arm-static.tar.gz && tar xzf ... curl -L -o qemu-aarch64-static.tar.gz https://github.com/.../qemu-aarch64-static.tar.gz && tar xzf ... curl -L -o qemu-s390x-static.tar.gz https://github.com/.../qemu-s390x-static.tar.gz && tar xzf ... curl -L -o qemu-i386-static.tar.gz https://github.com/.../qemu-i386-static.tar.gz && tar xzf ... } ``` -------------------------------- ### Start Node-RED in Debug Mode Source: https://github.com/node-red/node-red-docker/blob/master/README.md Use this command to start Node.js in debug mode, allowing remote debuggers to connect to port 9229. This is suitable for debugging a running application where startup code is not relevant. ```bash docker run -it -p 1880:1880 -p 9229:9229 -v node_red_data:/data --name mynodered --entrypoint npm nodered/node-red run debug -- --userDir /data ``` -------------------------------- ### Create Manifest List Version Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/build-system.md Creates and pushes a manifest list grouping architecture-specific images. Use for versioned releases. ```bash ./.docker/docker.sh manifest-list-version "20" "default" ./.docker/docker.sh manifest-list-version "" "minimal" ``` -------------------------------- ### Debug Entrypoint Execution with bash -x Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/entrypoint.md Enables verbose shell output for the entrypoint script, showing each command as it's executed. Useful for diagnosing startup issues. ```bash docker run ... --entrypoint "bash -x /usr/src/node-red/entrypoint.sh" ... ``` -------------------------------- ### Start a Stopped Node-RED Docker Container Source: https://github.com/node-red/node-red-docker/blob/master/README.md This command restarts a Node-RED Docker container that has been previously stopped. ```bash docker start mynodered ``` -------------------------------- ### Clone Node-RED Docker Repository Source: https://github.com/node-red/node-red-docker/wiki/Building-Custom-Image Clone the Node-RED Docker project from GitHub to start building custom images. ```shell git clone https://github.com/node-red/node-red-docker.git ``` -------------------------------- ### Build and Push All Architectures for Release Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/build-system.md Iterates through a list of architectures, building, testing, tagging, and pushing Docker images for each. This script automates the release process for multi-architecture support. ```bash for ARCH in amd64 arm32v6 arm32v7 arm64v8 s390x i386; do export ARCH=$ARCH export QEMU_ARCH=$(arch_to_qemu $ARCH) ./.docker/docker.sh build ./.docker/docker.sh test ./.docker/docker.sh tag ./.docker/docker.sh push done ``` -------------------------------- ### Create Manifest List Latest Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/build-system.md Creates a manifest list tagged as 'latest' for stable releases. Use for official releases. ```bash ./.docker/docker.sh manifest_list_latest "20" "default" ``` -------------------------------- ### Run Node-RED Docker Container without Healthcheck Source: https://github.com/node-red/node-red-docker/blob/master/README.md This command starts a Node-RED container and explicitly disables the healthcheck functionality. ```bash docker run -it -p 1880:1880 -v node_red_data:/data --name mynodered --no-healthcheck nodered/node-red ``` -------------------------------- ### Run Node-RED with Verbose Logging Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/entrypoint.md Passes the --verbose flag to Node-RED startup. This flag is captured by the entrypoint script and forwarded to the Node-RED process. ```bash docker run -it -p 1880:1880 -v node_red_data:/data nodered/node-red --verbose ``` -------------------------------- ### Dockerfile Multi-Stage Build Overview Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/types.md Outlines the three stages of the Dockerfile: base, build, and release. This approach optimizes the final image size by excluding build-time dependencies. ```dockerfile STAGES: 1. base - Installs system packages (bash, git, openssl, etc.) - Creates directories and users - Copies scripts and package.json - Sets up SSH configuration - Does NOT install node_modules (separate in build stage) 2. build - Installs npm build-essential packages - Runs: npm install --only=production - Copies prod_node_modules to shared path - Cleans up build tools in Alpine variant 3. release - Copies prod_node_modules from build stage - Sets environment variables - Configures npm cache directory - Sets user to node-red - Exposes port 1880 - Configures HEALTHCHECK - Sets ENTRYPOINT to entrypoint.sh ``` -------------------------------- ### Check Node-RED Container Health Status Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/quick-reference.md Inspect the health status of a running Node-RED container. The status can be 'healthy', 'unhealthy', or 'starting'. ```bash docker inspect --format='{{.State.Health.Status}}' mynodered ``` ```bash docker inspect mynodered | grep -A 5 '"Health":' ``` -------------------------------- ### Bind Mount Node-RED Data Directory Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/quick-reference.md Instructions for setting up a host directory as a bind mount for Node-RED data, including directory creation and permission setting. ```bash # Create directory mkdir -p ~/node-red/data # Set correct permissions (UID 1000 for node-red user) chown 1000:1000 ~/node-red/data chmod 755 ~/node-red/data # Mount in container docker run -v ~/node-red/data:/data ... ``` -------------------------------- ### Node-RED Container Startup in Safe Mode Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/quick-reference.md Starts a Node-RED container in safe mode, which prevents flows from running automatically on startup. ```bash docker run -it -p 1880:1880 -v node_red_data:/data -e NODE_RED_ENABLE_SAFE_MODE=true --name mynodered nodered/node-red ``` -------------------------------- ### Create Manifest List for Version Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/build-system.md Generates manifest lists for specific Node-RED versions and tag suffixes. This is crucial for managing multi-architecture image releases. ```bash ./.docker/docker.sh manifest-list-version "20" "default" ``` -------------------------------- ### Node-RED Container Startup with Debug Port Enabled Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/quick-reference.md Starts a Node-RED container with the Node.js inspector enabled on port 9229 for debugging. ```bash docker run -it -p 1880:1880 -p 9229:9229 -v node_red_data:/data --entrypoint npm nodered/node-red run debug -- --userDir /data ``` -------------------------------- ### Checking Container Health Status Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/healthcheck.md This command retrieves the current health status of a Docker container. The output can be 'healthy', 'unhealthy', or 'starting'. ```bash docker inspect --format='{{.State.Health.Status}}' mynodered # Output: healthy, unhealthy, or starting ``` -------------------------------- ### Create and Push Beta Release Tag Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/ci-pipeline.md Create an annotated Git tag for a beta release and push it to trigger builds for the development registry. Use a '-beta.N' suffix for beta versions. ```bash git tag -a v4.1.10-beta.1 -m "Beta release" git push origin v4.1.10-beta.1 ``` -------------------------------- ### Pull Older Node-RED Version Tags Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/image-tags.md Examples of how to pull older major versions of Node-RED Docker images, such as 3.x, 2.x, and 1.x. ```bash # Version 3.x docker pull nodered/node-red:3.1.0-20 # Version 2.x docker pull nodered/node-red:2.3.0-16 # Version 1.x docker pull nodered/node-red:1.3.0-10 ``` -------------------------------- ### Install Extra Python Packages in Dockerfile Source: https://github.com/node-red/node-red-docker/wiki/Building-Custom-Image Modify the `scripts/install_devtools.sh` script to include additional Python packages like `adafruit-circuitpython-neopixel` and `adafruit-circuitpython-motorkit`, which require `python3-dev`. ```shell #!/bin/bash set -ex # Installing Devtools if [[ ${TAG_SUFFIX} != "minimal" ]]; then echo "Installing devtools" apk add --no-cache --virtual devtools build-base linux-headers udev python python3 python3-dev pip3 install --upgrade pip pip3 install adafruit-circuitpython-neopixel pip3 install adafruit-circuitpython-motorkit else echo "Skip installing devtools" fi ``` -------------------------------- ### Access Node-RED Container via Interactive Shell Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/quick-reference.md Start an interactive shell session inside the Node-RED container. This is useful for debugging and manual inspection. ```bash docker run -it --entrypoint /bin/sh nodered/node-red ``` -------------------------------- ### Debug Node-RED Startup Logs Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/README.md Monitor the Node-RED container's startup logs in real-time to identify and troubleshoot issues. ```bash docker logs -f mynodered ``` -------------------------------- ### Run Node-RED Docker Container Source: https://github.com/node-red/node-red-docker/wiki/Home This command starts a Node-RED container, mapping port 1880 and assigning a name. It attaches a terminal for real-time logs. ```shell $ docker run -it -p 1880:1880 --name mynodered nodered/node-red ``` -------------------------------- ### Create and Connect Docker Containers to a Network Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/quick-reference.md Set up a custom Docker network and connect Node-RED and an MQTT broker to it. This enables automatic DNS resolution for inter-container communication. ```bash # Create network docker network create iot-network # Connect container docker run --network iot-network --name mynodered nodered/node-red # Connect MQTT broker docker run --network iot-network --name mqtt eclipse-mosquitto # In flows: use 'mqtt' as hostname (automatic DNS resolution) ``` -------------------------------- ### Run Node-RED with Custom Configuration Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/README.md Run a Node-RED container with custom configurations, including port mapping, volume mounting for data persistence, and environment variables for flow configuration and Node.js options. ```bash docker run -it \ -p 1880:1880 \ -v node_red_data:/data \ -e NODE_OPTIONS="--max_old_space_size=512" \ -e FLOWS=production_flows.json \ --name mynodered \ nodered/node-red ``` -------------------------------- ### Node-RED Docker Compose for Production Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/quick-reference.md A basic Docker Compose setup for running Node-RED in a production environment. It includes resource limits and reservations for containers. ```yaml version: "3.7" services: node-red: image: nodered/node-red:4.1.10-20 restart: unless-stopped ports: - "1880:1880" volumes: - node_red_data:/data environment: - TZ=UTC - NODE_OPTIONS=--max_old_space_size=1024 deploy: resources: limits: cpus: '2' memory: 1G reservations: cpus: '0.5' memory: 512M volumes: node_red_data: ``` -------------------------------- ### Tag Selection for Development/Testing Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/image-tags.md Use the minimal tag for faster pulls and smaller image size during development. The 'latest' tag can be used to test npm installations. ```bash # Use minimal for faster pulls and smaller size docker pull nodered/node-red:latest-minimal # Use with default variant to test npm installations docker pull nodered/node-red:latest ``` -------------------------------- ### Dockerfile Integration for Devtools Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/installation-scripts.md Shows how `install_devtools.sh` can be integrated into a Dockerfile, first as temporary 'buildtools' and then conditionally as permanent 'devtools'. ```dockerfile RUN apk add --no-cache --virtual buildtools build-base linux-headers udev python3 && \ npm install --unsafe-perm --no-update-notifier --no-fund --only=production && \ /tmp/remove_native_gpio.sh && \ cp -R node_modules prod_node_modules # ... later in release stage RUN /tmp/install_devtools.sh && \ rm -r /tmp/* ``` -------------------------------- ### Run Node-RED in Debug Mode with Breakpoint Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/quick-reference.md Start the Node-RED container with debugging enabled, exposing the debugger port (9229) and allowing remote connections for breakpoints. ```bash docker run -it -p 1880:1880 -p 9229:9229 \ -v node_red_data:/data \ --entrypoint npm \ nodered/node-red \ run debug_brk -- --userDir /data ``` -------------------------------- ### Set Timezone using Environment Variable Source: https://github.com/node-red/node-red-docker/blob/master/README.md Set the TZ environment variable to modify the default timezone within the container. This example sets the timezone to 'America/New_York'. ```bash docker run -it -p 1880:1880 -v node_red_data:/data --name mynodered -e TZ=America/New_York nodered/node-red ``` -------------------------------- ### Build Minimal Node-RED Image with Devtools Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/installation-scripts.md Use this Dockerfile to create a minimal Node-RED image that includes build tools like build-base and python3. ```dockerfile FROM nodered/node-red:latest-minimal RUN apk add --no-cache build-base python3 ``` -------------------------------- ### Usage in Dockerfile Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/ssh-known-hosts.md Demonstrates how to integrate the known_hosts script into a Dockerfile to set up SSH keys during image build. It also includes a step to configure SSH to accept RSA keys. ```dockerfile COPY .docker/known_hosts.sh . RUN ./known_hosts.sh /etc/ssh/ssh_known_hosts && rm /usr/src/node-red/known_hosts.sh RUN echo "PubkeyAcceptedKeyTypes +ssh-rsa" >> /etc/ssh/ssh_config ``` -------------------------------- ### Create and Push Docker Manifest Lists Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/ci-pipeline.md This section details the process of creating and pushing Docker manifest lists for multi-architecture support. It includes conditional logic for different release types (production, beta, dev, test). ```yaml jobs: include: - stage: manifest if: tag =~ ^v script: # Create and push Docker manifest lists # The push order is displayed in reverse order on Docker Hub # Docker Login - echo "$DOCKER_PASSWORD" | docker login -u "$DOCKER_USERNAME" --password-stdin # Create and push manifest list `version` for minimal - ./.docker/docker.sh manifest-list-version "12" "minimal" - ./.docker/docker.sh manifest-list-version "10" "minimal" - ./.docker/docker.sh manifest-list-version "" "minimal" # Create and push manifest list `version` for default - ./.docker/docker.sh manifest-list-version "12" "default" - ./.docker/docker.sh manifest-list-version "10" "default" - ./.docker/docker.sh manifest-list-version "" "default" # Create version-specific and latest manifest lists - > if [[ "${TARGET}" == "nodered/node-red" ]]; then # Production release manifest lists ./.docker/docker.sh manifest_list_latest ... elif [[ "${TRAVIS_TAG}" == *"beta"* ]]; then # Beta release manifest lists ./.docker/docker.sh manifest_list_beta ... elif [[ "${TRAVIS_TAG}" == *"dev"* ]]; then # Development manifest lists ./.docker/docker.sh manifest_list_dev ... else # Test manifest lists ./.docker/docker.sh manifest_list_test ... fi ``` -------------------------------- ### Node-RED Docker Build Context Structure Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/types.md Illustrates the directory structure and key files within the Docker build context and the user data volume. This defines the layout of the container's filesystem. ```bash /usr/src/node-red # WORKDIR in Dockerfile ├── entrypoint.sh # Container entry point script ├── package.json # npm package definitions ├── node_modules/ # Installed npm packages (after build) └── healthcheck.js # Health check validation script /data # User data volume ├── flows.json # Node-RED flow definitions ├── flows_creds.json # Encrypted flow credentials ├── settings.js # Node-RED configuration ├── .npm/ # npm cache directory └── / # Installed custom nodes ``` -------------------------------- ### Build Custom Node-RED Docker Image Source: https://github.com/node-red/node-red-docker/blob/master/README.md Creates a custom Docker image for Node-RED by extending the official image and installing an additional Node-RED module during the build process. ```dockerfile FROM nodered/node-red RUN npm install node-red-contrib-flightaware ``` -------------------------------- ### Run Docker Make Script Source: https://github.com/node-red/node-red-docker/wiki/Building-Custom-Image Execute the `docker-make.sh` script to build the custom Node-RED Docker image. This script uses build arguments to customize the image. ```shell ./docker-make.sh ``` -------------------------------- ### Dockerfile Release Stage Source: https://github.com/node-red/node-red-docker/blob/master/_autodocs/api-reference/installation-scripts.md This snippet illustrates the release stage of a multi-stage Dockerfile. It copies production modules from the build stage, sets ownership, and installs development tools. ```dockerfile FROM base AS release ARG BUILD_DATE ... COPY --from=build /usr/src/node-red/prod_node_modules ./node_modules RUN chown -R node-red:root /usr/src/node-red && \ /tmp/install_devtools.sh && \ rm -r /tmp/* ```