Solution 1: This won’t work every time
// run on host server
sysctl -w net.ipv4.ip_forward=1
sudo systemctl restart network
Solution 2: Append net.ipv4.ip_forward=1 to /etc/sysctl.conf file.
Solution 3: Append parameter —net=host to docker run, that will use host ports and ignore the -p parameters for example:
docker run -it --network host –name mynginx nginx
$ docker run -ti -p 8080:8080 -p 50000:50000 -v /opt/jenkins:/var/jenkins_home jenkins touch: cannot touch ‘/var/jenkins_home/copy_reference_file.log’: Permission denied Can not write to /var/jenkins_home/copy_reference_file.log. Wrong volume permissions?
If you meet the above error, please figure out your volume mapping permissions.
sudo chown -R 1000:1000 /opt/jenkins