Files
docker_practice/appendix/repo/nodejs.md
yeasy 6678e313ef Fix outdated versions, template variables and version inconsistencies
- Update K8s Dashboard v2.0.0 to v2.7.0
- Update etcd v3.4.0 to v3.5.17
- Update PostgreSQL 15 to 16 for consistency
- Update Node.js 12 to 20 (current LTS)
- Replace unresolved GitBook template variables (CODE1/2/3/9)
2026-03-14 08:45:42 -07:00

43 lines
933 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## Node.js
### 基本信息
[Node.js](https://en.wikipedia.org/wiki/Node.js) 是基于 JavaScript 的可扩展服务端和网络软件开发平台。
该仓库位于 `https://hub.docker.com/_/node/`具体可用版本以 Docker Hub 上的 tags 列表为准
### 使用方法
在项目中创建一个 Dockerfile
```docker
FROM node:20
## replace this with your application's default port
EXPOSE 8888
```
然后创建镜像并启动容器
```bash
$ docker build -t my-nodejs-app
$ docker run -it --rm --name my-running-app my-nodejs-app
```
也可以直接运行一个简单容器
```bash
$ docker run -it --rm \
--name my-running-script \
# -v "$ ":/usr/src/myapp \
--mount type=bind,src="$(pwd)",target=/usr/src/myapp \
-w /usr/src/myapp \
node:20-alpine \
node your-daemon-or-script.js
```
### Dockerfile
请到 https://github.com/docker-library/docs/tree/master/node 查看。