Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use docker to build hexo environment under OSX

2025-04-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to use docker to build a hexo environment under OSX". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

So far, there is no image build for the hexo 3 + version on docker hub.

As the Node environment takes a long time to install, it is relatively troublesome for people with more computers.

Building your own HEXO environment based on DockerFile is very flexible and can be customized according to your own situation.

You can import and export the replication environment and deploy it to other computers.

Practice begins docker installation

Most Linux, such as Ubuntu,Debian, can be installed with the following command:

Curl-sSL https://get.daocloud.io/docker | sh

TIP: don't forget to configure DaoCloud acceleration, otherwise the build speed will be slow.

Build docker build-t hexo3-

< hexo3.dockerfile hexo3.dockerfile 如下: FROM node:slim MAINTAINER Jianying Li # instal basic tool RUN apt-get update && apt-get install -y git ssh-client ca-certificates --no-install-recommends && rm -r /var/lib/apt/lists/*# set time zoneRUN echo "Asia/Shanghai" >

/ etc/timezone & & dpkg-reconfigure-f noninteractive tzdata# install hexoRUN npm install hexo@3.0.0-g # set base dirRUN mkdir / hexo# set home dirWORKDIR / hexo EXPOSE 4000 CMD ["/ bin/bash"]

Please note that the three most concise packages for customizing your own image are:

Git, used for deployment (remove it if you don't need git deployment).

Ssh-client (git deployment dependency in the ssh way).

Ca-certificates (git deployment dependency in the https way).

TIP: if you report an error when calling https to communicate in shell or lib

Problem with the SSL CA cert (path? Access rights?)

You can fix the problem by installing the package: ca-certificates, as is the case in yum apt.

The build time is about ten minutes to complete.

Prepare to mount the files on the physical machine (host) to docker

Install Guest Additions because you are using Shared Floader.

Use the command sudo mount-t vboxsf [sharename] [dist] to mount the shared directory.

Run docker run-it-d-p 4000 root/blog:/hexo/-- name hexo hexo3

Note that the path / root/blog/ is the location of the blog storage in my VirtualBox virtual machine.

Note that the parameter / root/blog/ requires an absolute path

Other parameters can easily find meaning in manual.

Backup and restore # docker save hexo3 > / root/hexo3.tar#docker load < / root/hexo3.tar

Note that you use save instead of export here because you need to save the history layer

Reference export size:

Du-h / root/hexo3.tar261M/root/hexo3.tar

From all the above work, compared with the virtual machine to build and package the environment, docker has the characteristics of shorter construction environment time and smaller packaging files.

Use containers to operate blogdocker exec-it hexo / bin/bash

Tip: although it is possible to build a very portable hexo environment with docker, running the command hexo is a bit slow, but not unbearably slow.

Tips

When debugging, you can use docker rm $(docker ps-Q-a) to delete all containers at once, and docker rmi $(docker images-Q) to delete all images at once.

This is the end of the content of "how to use docker to build a hexo environment under OSX". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 239

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report