docker-node
Manage nodes in a Docker Swarm cluster
TLDR
List nodes in the swarm
List tasks running on one or more nodes, defaults to the current node
Display detailed information on one or more nodes
Promote one or more nodes to manager in the swarm
Demote one or more nodes from manager in the swarm
Remove one or more nodes from the swarm
Update metadata about a node, such as its availability, labels, or roles
SYNOPSIS
docker build -t
docker run -d -p
PARAMETERS
Name to assign to the built Docker image.
Port on the host machine to forward traffic to.
Port that the Node.js application listens on within the container.
DESCRIPTION
While 'docker-node' isn't a standard Linux command, it represents a common practice: using Docker to containerize and run Node.js applications. The core idea revolves around creating a Docker image based on a Node.js base image (e.g., `node:
CAVEATS
Requires a Dockerfile in the current directory. Ensure your application correctly handles signals for graceful shutdown within the Docker container.
DOCKERFILE EXAMPLE
FROM node:16-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
This Dockerfile copies your application to the /app directory, install the dependencies using npm, exposes the port 3000 and starts your app using npm start
RUNNING WITH DOCKER COMPOSE
Docker Compose allows for managing multi-container applications. Here's an example docker-compose.yml:
version: "3.9"
services:
web:
build: .
ports:
- "3000:3000"
depends_on:
- db
db:
image: postgres:13
docker-compose up starts the entire application, including the Node.js web app and a PostgreSQL database.
SEE ALSO
docker(1), docker-compose(1)