DockerでFastDFSをデプロイする方法

以下の手順に従うと、Docker に FastDFS をデプロイできます。

  1. まずはDockerとDocker Composeがインストールされていることを確認
  2. 「docker-compose.yml」という名前のファイルを作成し、以下の内容を追加します。
version: '3'
services:
  tracker:
    image: season/fastdfs:tracker
    container_name: tracker
    ports:
      - 22122:22122
      - 8080:8080
    volumes:
      - ./data/tracker:/fastdfs/tracker
    restart: always
  storage:
    image: season/fastdfs:storage
    container_name: storage
    environment:
      - TRACKER_SERVER=tracker:22122
    volumes:
      - ./data/storage:/fastdfs/storage
    restart: always
  1. nginx.conf
events {
}

http {
    server {
        listen 8888;
        server_name localhost;
        location / {
            root /usr/local/nginx/html;
            index index.html;
        }
        
        location /group1/M00 {
            root /fastdfs/storage/data;
            ngx_fastdfs_module;
        }
    }
}
  1. Dockerfile
FROM nginx
COPY nginx.conf /etc/nginx/nginx.conf
  1. 下記のコマンドをコマンドラインで実行します。
docker-compose up -d

これにより、FastDFS の Tracker ノード、Storage ノード、Nginx コンテナが起動します。

  1. localhost:8080だよ
  2. http://localhost:8888 をネイティブの日本語で言い換えてください。1つのオプションだけでかまいません。

現在DockerにFastDFSを無事デプロイし、NGINX経由でファイルのアップロード、ダウンロードができるようになりました。

bannerAds