- 默认创建的容器, 修改/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即可