How to connect Portainer to another docker hub

I have created swarm in command line in my main node. Than I join to this swarm from slave node. Portainer in my main node show data in Network tab and Swarm tab correctly. OK.
Than I try create endpoint in my main node to manage my slave/secondary node. I found this instruction , but not understand it, because Portainer agent created in this instruction instead slave node in master node. why? This is no sense, because Agent can be create in secondare/slave node.
In other side I have opened Endpoint tab and after a lot of attempt still have not connect to second/slave node directly by docker API or to Portainer agent in secondary node. Why? What can be going wrong?
Do you have real instruction how to connect from Portainer to secondary/slave node? And instruction how to start Portainer Agent in secondary/slave node in swarm?

Thanks for posting, kindly refer and pl let us know your feedback
curl -L -o portainer-agent-stack.yml
docker stack deploy --compose-file=portainer-agent-stack.yml portainer