Skip to content
An`s Weblog
Go back

Using Volumes in Swarm Mode

1. Vấn đề của volume với Swarm mode

Giải pháp:

2. Quản lý Plugin Volume

docker plugin install <plugin_name>
docker plugin ls
docker plugin disable <plugin_id>
docker plugin rm <plugin_id>

Ví dụ cài rexray/dobs (DigitalOcean Block Storage):

docker plugin install rexray/dobs \
  DOBS_REGION=<region> \
  DIGITALOCEAN_TOKEN=<token> \
  CONVERTUNDERSCORES=true

Ví dụ AWS EBS:

docker plugin install rexray/ebs \
  AWS_ACCESSKEY=<access_key> \
  AWS_SECRETKEY=<secret_key> \
  AWS_REGION=<region>

3. Tạo Volume local

docker volume create -d local portainer_data

Volume này chỉ tồn tại trên node tạo.


4. Deploy Portainer service trên Swarm gắn Volume

docker service create \
  --name portainer \
  -p 8000:9000 \
  --constraint 'node.role==manager' \
  --mount type=volume,source=portainer_data,target=/data \
  --mount type=bind,source=/var/run/docker.sock,target=/var/run/docker.sock \
  portainer/portainer \
  -H unix:///var/run/docker.sock

5. Mở Portainer

6. Tổng kết

Thao tácCâu lệnh
Cài plugindocker plugin install
Tạo volumedocker volume create -d local <name>
Deploy service gắn volumedocker service create --mount
Ràng buộc service chạy trên manager--constraint 'node.role==manager'
Quản lý plugindocker plugin ls / disable / rm

Share this post:

Previous Post
Deploying Stacks in Docker Swarm
Next Post
Using Networks in Swarm Mode