10.修改sysctl.conf提示沒權限

  • 默認建立的容器, 修改/etc/sysctl.conf後執行sysctl -p提示只讀
docker_53# vim /etc/sysctl.conf
 net.ipv4.ip_forward = 1
docker_53# sysctl -p
docker error: "Read-only file system" setting key "net.ipv4.ip_forward"
  • 解決辦法以下
bash-3.2# docker run -itd --privileged -h docker_54 --name docker_54 centos:latest bash
bash-3.2# docker exec -it docker_54 bash
docker_54# vim /etc/sysctl.conf
 net.ipv4.ip_forward = 1
docker_54# sysctl -p
net.ipv4.ip_forward = 1
net.ipv4.tcp_syncookies = 1

建立容器時, 加上--privileged便可docker

相關文章
相關標籤/搜索