Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to set up daemon remote connection in docker

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article shows you how to set up daemon remote connection in docker. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

1. Set daemon listening connection:

Add local default listening port with IP:port mode

Ubuntu:

Modify the daemon configuration: / etc/docker/daemon.json, and add the following line:

The copy code is as follows:

{"hosts": ["fd://", "tcp://0.0.0.0:2375"]} (curly braces are required. If multiple lines are set, each line needs curly braces. If fd:// is set, it is automatically unix socket.

Restart docker:

Systemctl restart docker.service (Ubuntu16.04)

Check that "- H" indicates success.

Root@ubuntu:~# ps aux | grep dockerd root 113731 0.5 0.1 636160 47536? Ssl 10:54 0:00 / usr/bin/dockerd-H unix:///var/-H tcp://0.0.0.0 root@ubuntu:~# netstat-lant | grep 2375 tcp6 00: 2375: * LISTEN

Centos7:

/ etc/docker/daemon.json will be overwritten by the configuration file of docker.service, so adding daemon.json directly will not work. You can have the following settings:

1. Edit the configuration file directly: the docker daemon configuration file in Centos is in / lib/systemd/system/docker.service. Find the following fields and add the following fields. Note that "fd://" cannot be used here, otherwise an error will be reported.

... [Service]... ExecStart=/usr/bin/dockerd-H unix:///var/run/docker.sock-H tcp://0.0.0.0:2375

Execution

Systemctl daemon-reload systemctl restart docker.service

2. Systemctl edit docker.service, or edit vim / etc/systemd/system/docker.service.d/override.conf (must, not even one line less, and unix:// cannot write fd:// officially)

[Service] ExecStart= ExecStart=/usr/bin/dockerd-H unix:///var/run/docker.sock-H tcp://0.0.0.0:2375

Same execution

Systemctl daemon-reload systemctl restart docker.service

Finally, check whether it is successful. Add the-H parameter and start the port (the default port is 2375, but you can change it):

[root@myrepo docker.service.d] # ps aux | grep dockerd root 5567 8.02.0 632976 37696? Ssl 15:08 0:00 / usr/bin/dockerd-H tcp://0.0.0.0:2376-H unix:///var/run/docker.sock root 6143 0.0 112660 976 pts/0 S+ 15:08 0:00 grep-- color=auto dockerd [root@myrepo docker.service.d] # netstat-lant | grep 2376 tcp6 00: 2376: * LISTEN above is how to set daemon remote connection in docker Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report