docker安装Ghost博客

2018/08/24 17:28
阅读数 104

 1、安装docker-compose

curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose

2、mkdir ghost data nginx

ls #ls命令
data docker-compose.yml ghost nginx
 
vi docker-compose.yml
version: '2'

networks:
  ghost:

services:
  ghost-app:
    build: ghost
    networks:
      - ghost
    depends_on:
      - db
    ports:
      - "2368:2368"

  nginx:
    build: nginx
    networks:
      - ghost
    depends_on:
      - ghost-app
    ports:
      - "80:80"

  db:
    image: "mysql:5.7.15"
    networks:
      - ghost
    environment:
      MYSQL_ROOT_PASSWORD: mysqlroot
      MYSQL_USER: ghost
      MYSQL_PASSWORD: ghost
    volumes:
      - $PWD/data:/var/lib/mysql
    ports:
      - "3306:3306"

ghost 文件夹下

vi Dockerfile
FROM ghost
COPY ./config.js /var/lib/ghost/config.production.js
EXPOSE 2368
vi config.js
var path = require('path'),
config;

config = {
    production: {
        url: 'http://mytestblog.com',
        mail: {},
        database: {
            client: 'mysql',
            connection: {
                host     : 'db',
                user     : 'ghost',
                password : 'ghost',
                database : 'ghost',
                port: '3306',
                charset  : 'utf8'
            },
            debug: false
        },
        paths: {
                contentPath: path.join(process.env.GHOST_CONTENT,'/')
        },
        server: {
            host: '0.0.0.0',
            port: '2368'
        }
    }
};
module.exports = config;

nginx  文件夹下

vi Dockerfile
FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf
EXPOSE 80
vi nginx.conf
worker_processes 1;
events {worker_connections 1024;}
http {
    server {
        listen 80;
        location / {
            proxy_pass http://ghost-app:2368;
        }
    }
}
 
systemctl start docker.service #启动docker
 
docker-compose build #编译
docker-compose up -d #启动
 
docker-compose stop
docker-compose rm
 
docker ps
docker stop xxx
docker rm xxx
 
Ghost监听的端口是2368
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部