Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

Use hexo in docker. 在docker中使用 hexo 。

License

NotificationsYou must be signed in to change notification settings

ryjer/docker-hexo

Repository files navigation

buildxDocker StarsDocker PullsLicense: GPL v3

Usage

Use hexo in docker

1. Pull image

docker pull ryjer/hexo

2. Learn hexo

Read the basic usage of HexoBasic Usage

3. hexo init

docker run --rm -it \  -v$PWD:/hexo \  ryjer/hexo \  hexo init

4. hexo new

docker run --rm -it \  -v$PWD:/hexo \  ryjer/hexo \  hexo new [layout]<title>

5. hexo generate

docker run --rm -it \  -v$PWD:/hexo \  ryjer/hexo \  hexo generate

6. hexo server

docker run --name hexo -d \  -v$PWD:/hexo \  -p 80:4000 \  ryjer/hexo \  hexo server

More

Read the basic usage of HexoBasic Usage

使用说明:

你需要将 hexo 博客目录(该目录内会有_config.yml等文件source themes scaffolds 等文件夹)映射到 docker 容器中的/hexo 目录中,如果你需要hexo 作为服务器运行或者预览结果的话。还需要将端口映射到docker容器的4000 端口上。

一、拉取镜像

docker pull ryjer/hexo

问题:docker 中的npm 软件源为默认设置,可能会下载缓慢,你可以选择预先配置了淘宝npm源的镜像版本

docker pull ryjer/hexo:tb

二、进入 hexo 博客目录

# 具体路径由你决定,以下路径仅用于演示cd /root/hexo

三、hexo init 初始化hexo目录

详细命令见Hexo 官方文档链接

# 使用相对路径,在当前目录下进行 hexo init 初始化docker run --rm -it \  -v$PWD:/hexo \  ryjer/hexo:tb \  hexo init

四、hexo new 新建文章

# 使用相对路径,需要进入hexo 博客目录docker run --rm -it \  -v$PWD:/hexo \  ryjer/hexo:tb \  hexo new"文章标题"

五、hexo g 生成静态文件

注意:该命令会生成静态网站的所有文件到你映射目录(以下例子中为/root/hexo 目录)下的 public 文件夹中

# 使用相对路径,需进入一个hexo博客的目录docker run --rm -it \  -v$PWD:/hexo \  ryjer/hexo:tb \  hexo g

六、hexo s 启动服务器

hexo s 会将映射目录下的 public 目录(首先你要有public)挂载到网站根目录下,然后在容器内的 4000端口提供访问。所以需要额外映射主机端口,下面的例子中将本机80端口映射到容器的4000端口。

# 使用相对路径,需进入一个hexo博客的目录docker run --name hexo -d \  -v$PWD:/hexo \  -p 80:4000 \  ryjer/hexo:tb \  hexo s

其他:本镜像安装了hexo 和 git,需要除git之外其他软件包的命令可能会无法运行。

About

Use hexo in docker. 在docker中使用 hexo 。

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp