Docker开启远程访问(非认证模式)

CentOS 7 版本

# uname -r  
3.10.0-327.el7.x86_64  
# cat /etc/redhat-release  
CentOS Linux release 7.2.1511 (Core)   

docker 版本

# docker --version  
Client:
 Version:           18.09.0
 API version:       1.39
 Go version:        go1.10.4
 Git commit:        4d60db4
 Built:             Wed Nov  7 00:48:22 2018
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.0
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.10.4
  Git commit:       4d60db4
  Built:            Wed Nov  7 00:19:08 2018
  OS/Arch:          linux/amd64
  Experimental:     false

修改/usr/lib/systemd/system/docker.service

在ExecStart后面追加-H unix:///var/run/docker.sock -H 0.0.0.0:2375

[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
BindsTo=containerd.service
After=network-online.target firewalld.service
Wants=network-online.target

[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd -H unix:///var/run/docker.sock -H 0.0.0.0:2375
ExecReload=/bin/kill -s HUP $MAINPID
TimeoutSec=0
RestartSec=2
Restart=always

# Note that StartLimit* options were moved from "Service" to "Unit" in systemd 229.
# Both the old, and new location are accepted by systemd 229 and up, so using the old location
# to make them work for either version of systemd.
StartLimitBurst=3

# Note that StartLimitInterval was renamed to StartLimitIntervalSec in systemd 230.
# Both the old, and new name are accepted by systemd 230 and up, so using the old name to make
# this option work for either version of systemd.
StartLimitInterval=60s

# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity

# Comment TasksMax if your systemd version does not supports it.
# Only systemd 226 and above support this option.
TasksMax=infinity

# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes

# kill only the docker process, not all processes in the cgroup
KillMode=process

[Install]
WantedBy=multi-user.target

重启docker,让配置生效:

# systemctl daemon-reload  
# systemctl restart docker
# systemctl status docker

用netstat查看

[root@zabbix ~]# netstat -tnlp |grep 2375
tcp6       0      0 :::2375                 :::*                    LISTEN      17112/dockerd

 

用浏览器测试

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
开启Docker的远程安全访问,需要进行以下步骤: 1. 首先,需要修改Docker守护进程的配置文件。根据引用\[2\]中的内容,可以通过修改ExecStart属性值来实现。在ExecStart属性值中添加`--tlsverify`参数来启用TLS验证,`--tlscacert`参数指定TLS CA证书的路径,`--tlscert`参数指定TLS证书的路径,`--tlskey`参数指定TLS私钥的路径,`-H tcp://0.0.0.0:2375`参数指定Docker守护进程监听的远程访问端口。这样就可以开启Docker的远程安全访问。 2. 接下来,需要重新加载Docker守护进程的配置文件,以使修改生效。可以使用以下命令来重新加载配置文件:`sudo systemctl daemon-reload`。 3. 最后,重新启动Docker守护进程,使修改的配置生效。可以使用以下命令来重新启动Docker守护进程:`sudo systemctl restart docker`。 这样,Docker开启了远程安全访问,可以通过指定TLS证书和私钥来进行安全的远程通信。 #### 引用[.reference_title] - *1* *3* [Docker开启并配置远程安全访问](https://blog.csdn.net/qq_42263280/article/details/130116495)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Docker开放远程安全访问(开启2376端口和CA认证)](https://blog.csdn.net/guochengabcd/article/details/126284964)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^koosearch_v1,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值