Update 'docker_portainer_stacks/portainer/setup-dockerapi-notls'
This commit is contained in:
parent
f8c677aded
commit
79de6df9f4
@ -1,3 +1,4 @@
|
||||
|
||||
#!/bin/bash
|
||||
###################################
|
||||
############ by Sthope ############
|
||||
@ -7,17 +8,30 @@
|
||||
# bash -c "$(wget -qLO - https://git.sthope.dev/sthope/sthope-examples/raw/branch/master/docker_portainer_stacks/portainer/setup-dockerapi-notls)"
|
||||
#
|
||||
|
||||
findRandomTcpPort(){
|
||||
port=$(( 100+( $(od -An -N2 -i /dev/random) )%(1023+1) ))
|
||||
while :
|
||||
do
|
||||
(echo >/dev/tcp/localhost/$port) &>/dev/null && port=$(( 100+( $(od -An -N2 -i /dev/random) )%(1023+1) )) || break
|
||||
done
|
||||
echo "$port"
|
||||
}
|
||||
|
||||
|
||||
mkdir -p /etc/systemd/system/docker.service.d/
|
||||
|
||||
p=$(findRandomTcpPort)
|
||||
|
||||
cat << EOF > /etc/systemd/system/docker.service.d/startup_options.conf
|
||||
# /etc/systemd/system/docker.service.d/override.conf
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:2376
|
||||
ExecStart=/usr/bin/dockerd -H fd:// -H tcp://0.0.0.0:$p
|
||||
EOF
|
||||
|
||||
systemctl daemon-reload
|
||||
# systemctl daemon-reload
|
||||
|
||||
systemctl restart docker.service
|
||||
# systemctl restart docker.service
|
||||
|
||||
echo "You can now connect Portainer to this host at port: $p"
|
||||
|
||||
echo "You can now connect Portainer to this host."
|
Loading…
x
Reference in New Issue
Block a user