Why remote access to Docker?
- You can use the http protocol to obtain data in json format, which is very convenient
- Use code to control mirroring, so easy
How to configure it for remote access?
Create or modify this file: if not, add it~
/etc/systemd/system/docker.service.d/override.conf
write the following
##Add this to the file for the docker daemon to use different ExecStart parameters (more things can be added here)
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd
Note: By default when using systemd, docker.service is set to: ExecStart=/usr/bin/dockerd -H fd://, which will override any hosts written to daemon.json. By defining ExecStart in the override.conf file as just: ExecStart=/usr/bin/dockerd, this will use the hosts set in daemon.json. The first line ExecStart= in this file is required because it will be used to clear the default ExecStart parameter. If you modify the docker.service file instead of creating override.conf, then the next time systemd restarts, the docker.service file will also be recreated.
Then write the following in /etc/docker/daemon.json (if not, create a new one)
{
"hosts":[
"unix:///var/run/docker.sock",
"tcp://0.0.0.0:2375"
]
}
Edit the docker.server file
vi /usr/lib/systemd/system/docker.service
Find the [Service] node, modify the ExecStart attribute, and add
-H tcp://0.0.0.0:2375
reboot
test access
open port
Open firewall ports
firewall-cmd --add-port=2375/tcp --permanent
important
firewall-cmd --reload
Test access, you're done~
http://192.168.33.129:2375/version
I will write here today~
- Friends, ( ̄ω ̄( ̄ω ̄〃 ( ̄ω ̄〃)ゝ See you tomorrow~~
- Everyone be happy every day
Everyone is welcome to point out where the article needs to be corrected~
Learning is endless, cooperation is win-win