以root用户操作下载安装docker-compose

curl -L https://get.daocloud.io/docker/compose/releases/download/1.9.0/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

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

注释:su 切换root账户,如密码遗忘,sudo passwd root 修改密码。

目录结构

└── blog
    ├── data
    ├── docker-compose.yml
    ├── ghost
    │   ├── config.js
    │   └── Dockerfile
    └── nginx
        ├── Dockerfile
        └── nginx.conf

data/ghost目录的config.js

 

var path = require('path'),
config;

config = {
  production: {
    url: 'http://myb.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'
    }
  }
};

data/ghost目录的Dockerfile

FROM ghost
COPY config.js /var/lib/ghost/content/config.js
EXPOSE 2368

data/nginx目录的nginx.conf

worker_processes 4;

events {

   worker_connections 1024;
}

http{

   server {

      listen 80;

      location / {

           proxy_pass http://ghost-app:2368;

        }
   }

}

data/nginx目录的Dockerfile

FROM nginx
COPY nginx.conf /ect/nginx/nginx.conf
EXPOSE 80

data/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"

执行构建:

docker-compose up -d

21212121.png

Last modification:May 24, 2023
如果觉得我的文章对你有用,请随意赞赏