- Notifications
You must be signed in to change notification settings - Fork0
Use hexo in docker. 在docker中使用 hexo 。
License
NotificationsYou must be signed in to change notification settings
ryjer/docker-hexo
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Use hexo in docker
docker pull ryjer/hexo
Read the basic usage of HexoBasic Usage
docker run --rm -it \ -v$PWD:/hexo \ ryjer/hexo \ hexo init
docker run --rm -it \ -v$PWD:/hexo \ ryjer/hexo \ hexo new [layout]<title>
docker run --rm -it \ -v$PWD:/hexo \ ryjer/hexo \ hexo generate
docker run --name hexo -d \ -v$PWD:/hexo \ -p 80:4000 \ ryjer/hexo \ hexo server
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
# 具体路径由你决定,以下路径仅用于演示cd /root/hexo
详细命令见Hexo 官方文档链接
# 使用相对路径,在当前目录下进行 hexo init 初始化docker run --rm -it \ -v$PWD:/hexo \ ryjer/hexo:tb \ hexo init
# 使用相对路径,需要进入hexo 博客目录docker run --rm -it \ -v$PWD:/hexo \ ryjer/hexo:tb \ hexo new"文章标题"
注意:该命令会生成静态网站的所有文件到你映射目录(以下例子中为/root/hexo 目录)下的 public 文件夹中
# 使用相对路径,需进入一个hexo博客的目录docker run --rm -it \ -v$PWD:/hexo \ ryjer/hexo:tb \ hexo g
hexo s 会将映射目录下的 public 目录(首先你要有public)挂载到网站根目录下,然后在容器内的 4000端口提供访问。所以需要额外映射主机端口,下面的例子中将本机80端口映射到容器的4000端口。
# 使用相对路径,需进入一个hexo博客的目录docker run --name hexo -d \ -v$PWD:/hexo \ -p 80:4000 \ ryjer/hexo:tb \ hexo s