Home>Article>Operation and Maintenance> What should I do if docker cannot access the container?

What should I do if docker cannot access the container?

WBOY
WBOY Original
2022-02-07 10:14:10 6923browse

方法:1、用“vi/etc/sysctl.conf”命令修改“sysctl.conf”文件;2、在文件中添加“net.ipv4.ip_forward=1”;3、用“systemctl restart network”命令重启服务器网络即可。

What should I do if docker cannot access the container?

本教程操作环境:linux7.3系统、docker-1.13.1版、Dell G3电脑。

docker无法访问容器怎么办

首先根据以上提示信息大概搜索一下,基本都指向修改/etc/sysctl.conf文件

没有开启转发,网桥配置完后,需要开启转发,不然容器启动后,就会没有网络

vi /etc/sysctl.conf 或 vi /usr/lib/sysctl.d/00-system.conf

尝试修改,在sysctl.conf文件中追加以下

# 1代表启用 net.ipv4.ip_forward=1

然后使用以下命令重启服务器网络

systemctl restart network

再次通过浏览器访问docker容器相关服务,一切正常

查看是否修改成功

sysctl net.ipv4.ip_forward

如果返回为“net.ipv4.ip_forward = 1”则表示成功了。

推荐学习:《docker视频教程

The above is the detailed content of What should I do if docker cannot access the container?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn