I have installed manjaro on my old laptop and my friend also have a old laptop we both are trying to make a docker cluster
We have searched on google and chatgpt(from openai) and then we ran the following script
#!/bin/bash
# install Docker
sudo pacman -S docker
# start the Docker daemon
sudo systemctl start docker
# create a Docker swarm
docker swarm init --advertise-addr eth0
# get the join command and save it to a file
JOIN_COMMAND=$(docker swarm join-token worker -q)
echo $JOIN_COMMAND > join_command.txt
# create an overlay network
docker network create --driver overlay my-network
# deploy a service on the cluster
docker service create --name web-server --publish 8080:80 nginx
docker service scale web-server=3
Then i installed portainer
#!/bin/bash
# Create a Portainer container and mount it to the /data directory on the host
docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v /data:/data portainer/portainer
I was able to access on my local ip on port 9000
But my friend is not able to access it
I got public ip using
curl ifconfig.me
How can i make my friend access the docker container (portainer) or atleast how can he join the docker cluster?
Depends on how you are connected to the internet. For simple Home Internet via Cable or Landline, it usually means to configure port forwarding in your Home Router.
I m connected via wifi , i have only a local ipv4 in it, can u tell me how to configure port forward? I checked on chatgpt and it didn’t work it was
#!/bin/bash
# Install Docker
apt-get update
apt-get install -y docker.io
# Start Docker service
systemctl start docker
# Create a Portainer container and mount it to the /data directory on the host
docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v /data:/data portainer/portainer
# Set up dynamic DNS
apt-get install -y ddclient
echo "daemon=600
ssl=yes
use=web, web=myip.dnsdynamic.com
server=www.dnsdynamic.com
login=your_login
password='your_password'
your_hostname" > /etc/ddclient.conf
systemctl start ddclient
# Set up port forwarding on the router
# Replace <router_ip> with the IP address of your router
# Replace <local_ip> with the IP address of the machine where Portainer is running
# Replace <port> with the port number on which Portainer is listening (e.g., 9000)
curl -X POST -d '{"port_mappings": [{"local_ip": "<local_ip>", "public_port": <port>, "private_port": <port>, "protocol": "tcp"}]}' http://<router_ip>:8080/v1/port_mappings
# Get the public IP address of the router
PUBLIC_IP=$(curl http://checkip.dyndns.org/ | grep -Eo '[0-9\.]+')
echo "Portainer has been installed and is now running on port 9000."
echo "You can access the Portainer web interface from other networks by going to http://$PUBLIC_IP:<port> in a web browser,"
echo "where <port> is the port number on which Portainer is listening (e.g., 9000)."
EDIT: i just downloaded the package, app given in this script from yay and did the config given in it
No, nearly every Router model is different and need different steps. Most of them can only be configured via a Webinterface. Check out the manual of your Router or get in touch with your ISP.