文档

运行时容器镜像信息

更新时间:

镜像基本信息

  • 镜像名称:alinode

  • 镜像性质:公开

  • 公网地址:docker pull registry.cn-hangzhou.aliyuncs.com/aliyun-node/alinode

  • 经典内网:docker pull registry-internal.cn-hangzhou.aliyuncs.com/aliyun-node/alinode

  • VPC网络:docker pull registry-vpc.cn-hangzhou.aliyuncs.com/aliyun-node/alinode

  • 镜像版本

镜像内容

  • 与社区 Node.js 一一对应的运行时。对应关系

  • agenthub 源码

  • agenthub 启动脚本:置于容器根目录下。

 #!/bin/sh
ENABLE_NODE_LOG=NO node $HOME/default.config.js
if [ -f $HOME/agenthub-running.json ]; then
  ENABLE_NODE_LOG=NO agenthub start $HOME/agenthub-running.json
fi
exec "$@"

构建用户镜像(hello world)

mkdir test
touch hello.js
# 复制下面的 hello.js
touch Dockerfile
# 复制下面的 Dockerfie
docker build -t hello .

hello.js

const http = require('http');
http.createServer(function (req, res) {
  res.end('hello from alinode docker!\n');
}).listen(7001);

Dockerfile

FROM registry.cn-hangzhou.aliyuncs.com/aliyun-node/alinode:3.13.0
COPY ./hello.js /root/
CMD node /root/hello.js

运行用户镜像

docker run -d -p 7001:7001 -e "APP_ID=your_app_id" -e "APP_SECRET=your_app_secret" hello

创建应用,获得 appidsecret

传入 agenthub 配置的方法

通过命令行

 docker run -d -p 7001:7001 -e "APP_ID=your_app_id" -e "APP_SECRET=your_app_secret" hello

意:通过命令行只能传入 appidsecret

通过配置文件

将配置写到文件 process.env.HOME/app-config.json 中。

{
  "appid": "your_app_id",
  "secret": "your_app_secret",
  "error_log": ["/path/to/your/error.log"],
  "packages": ["/path/to/your/package.json"]
}

意:在制作用户镜像时,配置文件只能是 process.env.HOME/app-config.json。文件名和路径都不能更改。

如果使用 egg 集成框架

无需启动 agenthub。

注意

  • 容器内 coredump 生成规则会继承宿主机设置,如果 core_pattern 指定了一个容器中不存在的应用来处理,会造成无法生成 coredump。下面是几个 core_pattern 的例子。值得注意的是,如果指定由 apport 来处理,然而容器内没有安装 apport,那么 coredump 就不会生成。

# 生成的coredump存放在/cloud/data/corefile/目录
# %e 程序名称
# %p pid
# %t dump的时间
# %h hostname
cat /proc/sys/kernel/core_pattern 
/cloud/data/corefile/core-%e-%p-%t-%h

# 生成coredump到当前目录,文件名为core,如果已经存在core文件,那么新的coredump不会生成
cat /proc/sys/kernel/core_pattern 
core

# coredump由 apport 来处理
# /usr/share/apport/apport <pid> <signal number> <core file ulimit> <dump mode> [global pid]
cat /proc/sys/kernel/core_pattern
|/usr/share/apport/apport %p %s %c
  • 本页导读 (0)
文档反馈