美文网首页
Docker[note_10]docker安装Node,使用He

Docker[note_10]docker安装Node,使用He

作者: 墨流引 | 来源:发表于2020-03-24 09:53 被阅读0次

拉取镜像

$ docker pull node:13
Pulling from library/node
c0c53f743a40: Pull complete
584bf23912b7: Downloading [============================================>      ]   44.8MB/50.07MB
3c4c73959f29: Downloading [==========================================>        ]  184.2MB/214.9MB
3c4c73959f29: Pull complete
63e05266fc4b: Pull complete
7b37ba8cd979: Pull complete
3a18f94fe18a: Pull complete
a000f3263f8b: Pull complete
Digest: sha256:4fcd0936b8***b8c154112e27
Status: Downloaded newer image for node:13

创建容器

docker run -id \
-p 4000:4000 \
--name node_hexo \
-v /var/doc_vol/nodelib/hexo_web:/root/hexo_web \
node:13

$ docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                              NAMES
cfab68ff15ed        node:13             "docker-entrypoint.s…"   13 seconds ago      Up 12 seconds       0.0.0.0:4000->4000/tcp             node_hexo

$ docker inspect node_hexo
[
    {
        "Id": "cfab68ff14acb1c44e***999e253181ed0f49",
        "Created": "2020-03-23T11:34:02.755407175Z",
        "Path": "docker-entrypoint.sh",
        "Args": [
            "node"
        ],
        ...

        "Mounts": [
            {
                "Type": "bind",
                "Source": "/var/doc_vol/nodelib/hexo_web",
                "Destination": "/root/hexo_web",
                "Mode": "",
                "RW": true,
                "Propagation": "rprivate"
            }
        ],
        ...
    }
]

进入容器

$ docker exec -it node_hexo bash

安装Hexo

$ npm install hexo-cli -g
$ hexo init blog
$ cd blog
$ npm install
$ hexo server

启动Hexo服务

$ docker exec \
-id node_hexo \
-w /root/hexo_web \
bash \
hexo server

切换任务到后台运行


INFO  Start processing
INFO  Hexo is running at http://localhost:4000 . Press Ctrl+C to stop.
^Z
# 使用CTRL+Z暂停当前任务
[1]+  Stopped                 hexo s
$ jobs -l
[1]+  1009 Stopped                 hexo s
$ bg %1
# 将任务切换到后台运行
[1]+ hexo s &
$ jobs -l
[1]+  1009 Running                 hexo s &
$ exit
# 退出容器

相关文章

网友评论

      本文标题:Docker[note_10]docker安装Node,使用He

      本文链接:https://www.haomeiwen.com/subject/wuxgyhtx.html