Pin a file to a specific peer in ipfs cluster

Dear All,
I am new in learning ipfs technologies. I have successfully run ipfs cluster using docker-compose.yaml file.
When I pin a file, it is pinned to all cluster peers.
My intention is to pin my file to a specific peer in the cluster peer
how can I modify the docker-compose file for this purpose?

version: β€˜3.4’
services:

cluster peer0

ipfs0:
container_name: ipfs0
image: ipfs/go-ipfs:release
ports:
- β€œ4001:4001” # ipfs swarm - expose if needed/wanted
- β€œ5001:5001” # ipfs api - expose if needed/wanted
- β€œ8080:8080” # ipfs gateway - expose if needed/wanted
volumes:
- ./data/ipfs0:/data/ipfs

cluster0:
container_name: cluster0
image: ipfs/ipfs-cluster:latest
depends_on:
- ipfs0
environment:
CLUSTER_PEERNAME: cluster0
CLUSTER_SECRET: f5cd39fc1145a3efadb3fc36ad36c9279fe34fe1e6e289ee7b5be79615dccd6f # From shell variable if set
CLUSTER_IPFSHTTP_NODEMULTIADDRESS: /dns4/ipfs0/tcp/5001
CLUSTER_CRDT_TRUSTEDPEERS: β€˜*’ # Trust all peers in Cluster
CLUSTER_RESTAPI_HTTPLISTENMULTIADDRESS: /ip4/0.0.0.0/tcp/9094 # Expose API
CLUSTER_MONITORPINGINTERVAL: 2s # Speed up peer discovery
ports:
# Open API port (allows ipfs-cluster-ctl usage on host)
- β€œ9094:9094”
# The cluster swarm port would need to be exposed if this container
# was to connect to cluster peers on other hosts.
# But this is just a testing cluster.
# - β€œ9096:9096” # Cluster IPFS Proxy endpoint
volumes:
- ./data/cluster0:/data/ipfs-cluster

cluster peer1

ipfs1:
container_name: ipfs1
image: ipfs/go-ipfs:release
volumes:
- ./data/ipfs1:/data/ipfs

cluster1:
container_name: cluster1
image: ipfs/ipfs-cluster:latest
depends_on:
- ipfs1
environment:
CLUSTER_PEERNAME: cluster1
CLUSTER_SECRET: f5cd39fc1145a3efadb3fc36ad36c9279fe34fe1e6e289ee7b5be79615dccd6f

  CLUSTER_IPFSHTTP_NODEMULTIADDRESS: /dns4/ipfs1/tcp/5001
  CLUSTER_CRDT_TRUSTEDPEERS: '*'
  CLUSTER_MONITORPINGINTERVAL: 2s # Speed up peer discovery
volumes:
  - ./data/cluster1:/data/ipfs-cluster

cluster peer2

ipfs2:
container_name: ipfs2
image: ipfs/go-ipfs:release
volumes:
- ./data/ipfs2:/data/ipfs

cluster2:
container_name: cluster2
image: ipfs/ipfs-cluster:latest
depends_on:
- ipfs2
environment:
CLUSTER_PEERNAME: cluster2
CLUSTER_SECRET: f5cd39fc1145a3efadb3fc36ad36c9279fe34fe1e6e289ee7b5be79615dccd6f

  CLUSTER_IPFSHTTP_NODEMULTIADDRESS: /dns4/ipfs2/tcp/5001
  CLUSTER_CRDT_TRUSTEDPEERS: '*'
  CLUSTER_MONITORPINGINTERVAL: 2s # Speed up peer discovery
volumes:
  - ./data/cluster2:/data/ipfs-cluster

cluster peer3

ipfs3:
container_name: ipfs3
image: ipfs/go-ipfs:release
volumes:
- ./data/ipfs3:/data/ipfs

cluster3:
container_name: cluster3
image: ipfs/ipfs-cluster:latest
depends_on:
- ipfs3
environment:
CLUSTER_PEERNAME: cluster3
CLUSTER_SECRET: f5cd39fc1145a3efadb3fc36ad36c9279fe34fe1e6e289ee7b5be79615dccd6f

  CLUSTER_IPFSHTTP_NODEMULTIADDRESS: /dns4/ipfs3/tcp/5001
  CLUSTER_CRDT_TRUSTEDPEERS: '*'
  CLUSTER_MONITORPINGINTERVAL: 2s # Speed up peer discovery
volumes:
  - ./data/cluster3:/data/ipfs-cluster

cluster peer4

ipfs4:
container_name: ipfs4
image: ipfs/go-ipfs:release
volumes:
- ./data/ipfs4:/data/ipfs

cluster4:
container_name: cluster4
image: ipfs/ipfs-cluster:latest
depends_on:
- ipfs4
environment:
CLUSTER_PEERNAME: cluster4
CLUSTER_SECRET: f5cd39fc1145a3efadb3fc36ad36c9279fe34fe1e6e289ee7b5be79615dccd6f

  CLUSTER_IPFSHTTP_NODEMULTIADDRESS: /dns4/ipfs4/tcp/5001
  CLUSTER_CRDT_TRUSTEDPEERS: '*'
  CLUSTER_MONITORPINGINTERVAL: 2s # Speed up peer discovery
volumes:
  - ./data/cluster4:/data/ipfs-cluster

cluster peer5

ipfs5:
container_name: ipfs5
image: ipfs/go-ipfs:release
volumes:
- ./data/ipfs5:/data/ipfs

cluster5:
container_name: cluster5
image: ipfs/ipfs-cluster:latest
depends_on:
- ipfs5
environment:
CLUSTER_PEERNAME: cluster5
CLUSTER_SECRET: f5cd39fc1145a3efadb3fc36ad36c9279fe34fe1e6e289ee7b5be79615dccd6f

  CLUSTER_IPFSHTTP_NODEMULTIADDRESS: /dns4/ipfs5/tcp/5001
  CLUSTER_CRDT_TRUSTEDPEERS: '*'
  CLUSTER_MONITORPINGINTERVAL: 2s # Speed up peer discovery
volumes:
  - ./data/cluster5:/data/ipfs-cluster

When you send the pin you can specify the --allocations flag.

You can also override the replication factors via ENV VARs in the compose file:

CLUSTER_REPLICATION_FACTOR_MAX and CLUSTER_REPLICATION_FACTOR_MIN.

Thank you so much for your quick response.
./cluster-ctl pin add --replication 1 --allocations (peer1…) (file name) it gives error
error : invalid path β€œphoto.png”: selected encoding not supported

./cluster-ctl pin add --replication 1 --allocations (peer1…) (CIF of the file)
It works.
but it requires the CID of the file. is it possible to add a file with just a name to a specific peer?

you can do ipfs-cluster-ctl add --allocations <> photo.png


But it replicates in all peers

add --replication-factor 1 too.


It is not working either.

replcation ?
You have a typo.


Same

Run ipfs-cluster-ctl add --help to see what actual options exist.

Can nodes in the cluster be grouped according to tag:region or tag:group? Can a node specify which groups to update synchronously when uploading content, and update the rest from other groups? It is better to specify which groups to fix several nodes

I don’t think this is possible.