(云原生之使用Docker部署Ghost个人博客)
一、检查本地系统版本
[root@docker ~]# cat /etc/os-release
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"
CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
二、检查本地docker环境
1.检查docker版本
[root@docker ~]# docker -v
Docker version 20.10.18, build b40c2f6
2.检查docker状态
[root@docker ~]# systemctl status docker
● docker.service - Docker Application Container Engine
Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2022-10-25 11:40:20 CST; 9h ago
Docs: https://docs.docker.com
Main PID: 9403 (dockerd)
Tasks: 91
Memory: 1.3G
CGroup: /system.slice/docker.service
三、下载Ghost镜像
[root@docker ~]# docker pull ghost
Using default tag: latest
latest: Pulling from library/ghost
72a69066d2fe: Already exists
24892ef5fd86: Pull complete
b352cb85f08b: Pull complete
d184ccfb32cc: Pull complete
a1aa0950435d: Pull complete
6af76194e172: Pull complete
6ecb9543cf3f: Pull complete
f5dc5f4a448f: Pull complete
c5c6987f6d28: Pull complete
Digest: sha256:8123a7eabc533746cfa7302c71b780e763ee292f92c10f44e12d08baa0b489f9
Status: Downloaded newer image for ghost:latest
docker.io/library/ghost:latest
四、创建Ghost容器
1.创建数据目录
[root@docker ~]# mkdir -p /data/ghost
[root@docker ~]# cd /data/ghost/
[root@docker ghost]#
2.目录授权
chmod -R 777 /data/ghost/
3.创建Ghost容器
docker run -d \
--restart always \
--name ghost \
-p 2368:2368 \
-v $(pwd)/data:/var/lib/ghost/content \
-e NODE_ENV=development \
-e url=http://192.168.3.232:2368 \
ghost
4.检查Ghost容器状态
[root@docker ghost]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
66dd8a21b646 ghost "docker-entrypoint.s…" 28 seconds ago Up 26 seconds 0.0.0.0:2368->2368/tcp, :::2368->2368/tcp ghost