Master Node Machine : 192.168.2.80
Node 1 Machine : 192.168.2.81
Master Node Machine
1 2 3 4 5 6 7 8 9 |
tmux new-session -d -s app tmux new-window -t app:1 -n 'docker-shell' sudo apt update && sudo apt install -y sshfs nfs-kernel-server sudo ssh-keygen -t rsa cat ~/.ssh/id_rsa.pub >> /tmp/id_rsa.pub |
result
1 |
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDl1s/aSpaE2H6+OR2ili5F6BYWik/vvn+qg/g1OP2On root@vm-master |
Copy it to your clipboard
1 2 3 4 5 |
touch ~/.ssh/authorized_keys cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys |
Node 1 Machine
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
sudo apt update && sudo apt install -y sshfs nfs-common curl tmux new-session -d -s app tmux new-window -t app:1 -n 'docker-shell' sudo ssh-keygen -t rsa cat ~/.ssh/id_rsa.pub >> /tmp/id_rsa.pub touch ~/.ssh/authorized_keys cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys chmod 600 ~/.ssh/authorized_keys |
1 |
nano ~/.ssh/authorized_keys |
Paste ssh-key from Master Machine to last line and save it.
Test ssh connection
1 |
ssh root@192.168.2.80 -p 22 |
1 |
exit |
1 |
cat /tmp/id_rsa.pub |
Copy ssh-key to clipboard and back to Master Node
Master Node
1 |
nano ~/.ssh/authorized_keys |
Paste ssh-key from Node 1 Machine to last line and save it.
Test ssh connection
1 |
ssh root@192.168.2.81 -p 22 |
1 |
exit |
Installing NetShare
1 2 3 4 5 6 7 8 9 |
wget https://github.com/ContainX/docker-volume-netshare/releases/download/v0.34/docker-volume-netshare_0.34_amd64.deb sudo dpkg -i docker-volume-netshare_0.34_amd64.deb mkdir /opt/nginx/ sudo chown -R nobody:nogroup /opt/nginx/ service docker-volume-netshare start |
1 |
sudo nano /etc/exports |
1 |
/opt/nginx 192.168.2.81(rw,sync,root_squash,subtree_check) |
1 |
sudo systemctl restart nfs-kernel-server |
Node 1 Machine
1 2 3 4 5 6 7 |
mkdir /opt/nginx sudo mount -t nfs4 192.168.2.80:/opt/nginx /opt/nginx service docker-volume-netshare start tmux a -t app |
on tab ‘docker-shell’
1 |
sudo docker-volume-netshare nfs |
on tab ‘bash’
1 |
docker volume create -d nfs --name nginxdata -o share=192.168.2.80:/opt/nginx |
1 |
nano /opt/nginx/index.html |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<!DOCTYPE html> <html> <head> <title>Docker nginx!</title> <style> body { width: 35em; margin: 0 auto; font-family: Tahoma, Verdana, Arial, sans-serif; } </style> </head> <body> <h1>Welcome to nginx!</h1> <p>If you see this page, the nginx web server is successfully installed and working. Further configuration is required.</p> <p>For online documentation and support please refer to <a href="http://nginx.org/">nginx.org</a>.<br/> Commercial support is available at <a href="http://nginx.com/">nginx.com</a>.</p> <p><em>Docker nginx</em></p> </body> </html> |
1 |
docker run --name nginx -v nginxdata:/usr/share/nginx/html -d -p 8080:80 nginx:1.15.5 |
Testing
1 |
curl -i http://192.168.2.81:8080 |
then try to remove container
1 2 3 4 5 6 7 |
docker container stop nginx docker container rm nginx docker volume rm nginxdata ls /opt/nginx |