問題描述
在打開防火墻的情況下,通過http啟動(dòng)docker容器報(bào)500錯(cuò)誤
解決過程
1.查看2375端口是否開放
firewall-cmd --query-port=2375/tcp
2.檢查外部網(wǎng)絡(luò)是否可以訪問服務(wù)器
直接在瀏覽器輸入http://192.xxx.xxx.xxx:2375/containers/json?all=true
看是否有返回
結(jié)果是有返回,代表外部網(wǎng)絡(luò)連接服務(wù)器沒問題
3.查看ip轉(zhuǎn)發(fā)
sysctl net.ipv4.ip_forward
坑
看起來ip轉(zhuǎn)發(fā)是正常的,但問題也就出現(xiàn)在這里,查看/etc/sysctl.conf文件,發(fā)現(xiàn)里面并沒有ip轉(zhuǎn)發(fā)相關(guān)配置
cat /etc/sysctl.conf
4.成功解決
在 /etc/sysctl.conf里,將net.ipv4.ip_forward=1
添加進(jìn)去就好文章來源:http://www.zghlxwxcb.cn/news/detail-536341.html
[root@xxx ~]# cat /etc/sysctl.conf
# sysctl settings are defined through files in
# /usr/lib/sysctl.d/, /run/sysctl.d/, and /etc/sysctl.d/.
#
# Vendors settings live in /usr/lib/sysctl.d/.
# To override a whole file, create a new file with the same in
# /etc/sysctl.d/ and put new settings there. To override
# only specific settings, add a file with a lexically later
# name in /etc/sysctl.d/ and put new settings there.
#
# For more information, see sysctl.conf(5) and sysctl.d(5).
net.ipv4.ip_forward=1
之后再重新加載配置文件和重啟docker文章來源地址http://www.zghlxwxcb.cn/news/detail-536341.html
systemctl daemon-reload
systemctl restart docker
5.測試
@Test
public void startDocker(){
String url="http://192.xxx.xxx.xxx:2375";
String envId="n8fd1c2e61cf7963e5b1c9c1af00b8134e5c71915059c4a465fb3bad827abb19f";
restTemplate.postForObject(url + "/containers/" + envId + "/start", null, Object.class);
}
到了這里,關(guān)于記一次問題解決:通過http啟動(dòng)docker容器報(bào)500錯(cuò)誤的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!