How to deploy FastDFS in Docker

How to deploy FastDFS in Docker

Install fastdfs on Docker

Mount directory

-v /e/fdfs/tracker:/var/fdfs

/e/fdfs/tracker The folder path in windows is E:\fdfs\tracker

/var/fdfs is the absolute path of the file in the container

View Network

docker network ls # Network list docker network create --driver bridge --subnet=192.168.127.0/24 fastdfs_fastdfs_net # Create a custom network segment not in use yet

Download image

docker pull season/fastdfs

Create a tracker container. The default port of the Tracker server is 22122.

## The deployment process uses the bridge network docker run -ti -d --name trakcer -v /f/fastdfs/tracker_data:/fastdfs/tracker/data -p 22122:22122 season/fastdfs tracker

Use Docker images to build storage containers (storage servers that provide capacity and backup services)

## 172.17.0.2 is the IP address of the containerdocker run -tid --name storage -v /f/fastdfs/storage_data:/fastdfs/storage/data -v /f/fastdfs/store_path:/fastdfs/store_path -p 8080:8080 -p 23000:23000 -p 80:80 -e TRACKER_SERVER:172.17.0.2:22122 -e GROUP_NAME=group1 season/fastdfs storage

At this point both services are started

### Configure the service, enter the storage container, and configure the port for http access in the storage configuration file. The configuration file is in storage.conf in the fdfs_conf directory.
docker exec -it storage bash
cd fdfs_conf
more storage.conf

Next, exit the storage container and copy the configuration file:

docker cp storage:/fdfs_conf/storage.conf ./

Copy the modified configuration file to the storagee configuration directory:

docker cp ./storage.conf storage:/fdfs_conf/

Restart the storage container

docker stop storage
docker start storage

See the association between the tracker container and the storage container

docker exec -it storage bash
cd fdfs_conf
fdfs_monitor storage.conf 

Upload files to the storage container in docker simulate client

## Open a client docker cp ./storage.conf fdfs_sh:/fdfs_conf/

Change the configuration file. Since it has been changed once before, just copy it now.

docker exec -it fdfs_sh bash

Create a txt file

docker exec -it fdfs_sh bash
echo hello>a.txt

Enter the fdfs_conf directory and upload the file to the storage container

cd fdfs_conf

fdfs_upload_file storage.conf /a.txt

Windows Commands

netstat -aon|findstr "22122" # Check if the port is disabled netsh firewall set opmode mode=disable # Disable the firewall netsh firewall reset

https://hub.docker.com/r/qbanxiaoli/fastdfs)

Install and configure image acceleration using docker-toolbox in Windows Server 2012 R2 environment

docker-machine ssh default
sudo sed -i "s|EXTRA_ARGS='|EXTRA_ARGS='--registry-mirror=http://hub-mirror.c.163.com |g" /var/lib/boot2docker/profile
exit
docke-machine restart default

Docker installation prompt: Error response from daemon: client is newer than server

Solution: Use the command docker version to check the client version, and then simply change the client version to be consistent with the server version (export DOCKER_API_VERSION=1.22) Copy code

DockerToolbox prompts: default Boot2Docker ISO is out-of-date

Solution: This problem can be solved by downloading and copying the latest version of the boot2docker.iso file and placing it in the installation directory and cache directory.

Download the latest version of boot2docker.iso image, official download address: https://github.com/boot2docker/boot2docker/releases Copy it to the local cache directory ( C:\Users\admin.docker\machine\cache\ ), and copy it to the local installation directory ( C:\Program Files\Docker Toolbox ), run -Docker again Run -Docker Quickstart Termina l terminal console again, and you can create the ```default`` virtual machine normally.

If the above error message is still displayed, it is because the version of boot2docker.iso is not the latest one. At startup, the system will connect to the Internet to check and download the latest boot2docker.iso . However, the access speed github is very slow, which causes the system to get stuck. Therefore, the network is disconnected and the check step is skipped. After loading boot2docker.iso , there will be no problem in opening docker later.

Mounting Folders

https://www.jb51.net/article/176813.htm

Fastdfs integrated SpringBoot configuration

#FastDFS
fdfs:
  so-timeout: 1501
  connect-timeout: 601
  thumb-image: #thumbnail generation parameters width: 200
    height: 200
  tracker-list:
    - 192.168.118.162:22122

How to directly access the docker for windows container intranet through an independent IP

Implementing IP intercommunication by configuring routing tables

View route print

## Add route route -p add 172.17.0.0 MASK 255.255.255.0 10.0.75.2

How to directly access the docker for windows container intranet through an independent IP

Docker deployment FastDfs--Method 2

-v /e/fdfs/tracker:/var/fdfs

/e/fdfs/tracker The folder path in windows is E:\fdfs\tracker

/var/fdfs is the absolute path of the file in the container

clone project

## This image is an image with Nginx integrated. git clone https://[email protected]/qbanxiaoli/fastdfs.git 

Enter the fastdfs directory

cd fastdfs

Modify docker-compose.yml and change ip

shellversion: '3.0'
services:
 fastdfs:
  build: .
  image: qbanxiaoli/fastdfs
  # Whether the container needs to be started and automatically restarted. Uncomment if necessary.
  restart: always
  container_name: fastdfs
  ports:
   - 8080:8080
   - 22122:22122
   - 23000:23000
  environment:
   # Use TZ: Asia/Shanghai
   # nginx service port, default port 8080, can be modified WEB_PORT: 8080
   # tracker_server service port, default port 22122, can be modified FDFS_PORT: 22122
   # Fastdht service port, default port 11411, can be modified FDHT_PORT: 11411
   # The IP intranet address of the host machine where Docker is located. By default, the IP address of the eth0 network card is used: 192.168.118.93
  volumes:
   # Map the local directory to the fastdfs data storage directory in the docker container, and store the fastdfs files on the host to avoid losing the previously stored files every time the docker container is rebuilt.
   - /e/fastdfs/fastdfs:/var/local
  # Since Windows and Unix cannot recognize the host network, a new network segment needs to be created to force the container IP to be consistent with the host IP networks:
   fastdfs_net:
    ipv4_address: 192.168.118.93

networks:
 fastdfs_net:
  driver: bridge
  driver_opts:
   parent: eth0
  ipam:
   config:
    - subnet: 192.168.118.0/24

Execute the docker-compose command

shelldocker-compose up -d

Test whether fastdfs is successfully built

# Enter the container docker exec -it fastdfs /bin/bash

Restart tracker_server

shell/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf restart

Restart storage_server

shell/usr/bin/fdfs_storaged /etc/fdfs/storage.conf restart

View storage status

shellfdfs_monitor /etc/fdfs/client.conf

localhost:8080 access nginx

Indicates that the deployment was successful!

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • Detailed example of installing FastDfs file server using docker compose
  • Some notes on installing fastdfs image in docker
  • Building FastDFS file system in Docker (multi-image tutorial)
  • How to install FastDFS in Docker
  • How to use docker compose to build fastDFS file server

<<:  Simple tutorial on using Navicat For MySQL

>>:  Vue routing returns the operation method of restoring page status

Recommend

XHTML introductory tutorial: Web page Head and DTD

Although head and DTD will not be displayed on th...

JavaScript implements large file upload processing

Many times when we process file uploads, such as ...

How to view available network interfaces in Linux

Preface The most common task after we install a L...

Example of how to deploy Spring Boot using Docker

Here we mainly use spring-boot out of the box, wh...

Vue conditional rendering v-if and v-show

Table of contents 1. v-if 2. Use v-if on <temp...

SQL implementation of LeetCode (177. Nth highest salary)

[LeetCode] 177.Nth Highest Salary Write a SQL que...

Vue uses Amap to realize city positioning

This article shares the specific code of Vue usin...

Summary of some common configurations and techniques of Nginx

Preface This article lists several common, practi...

Instructions for recovering data after accidental deletion of MySQL database

In daily operation and maintenance work, backup o...

How to convert MySQL horizontally to vertically and vertically to horizontally

Initialize Data DROP TABLE IF EXISTS `test_01`; C...