Docker under LXC change default network

tbaror

Member
Jan 21, 2022
6
0
6
54
i installed docker under lxc container ,i always change the defualt docker0 network by putting deamon.js file under /etc/docker, with following content below , but even after rebooting or service restart the network range stays the same, when executing ip addr i get following

any idea what is wrong?

Please advice

Code:
docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:6f:a7:93:af brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever

JSON:
{
 "default-address-pools":
 [
 {"base":"172.20.0.0/16","size":24}
 ]
}
 
Hi,

so first of, the file must be called /etc/docker/daemon.json, not deamon.json. Just in case this wasn't just a typo here.

And secondly, default-address-pools configures the IP-range available to the containers, not the bridge itself.
To configure the docker0 bridge, use the bip key, e.g.
Code:
{
    "bip": "172.20.0.1/16"
}

Just a word of warning: Running Docker in a LXC is generally strongly advised against, since it more often than not just creates more problems than it really solves. It's best to just run it in a VM and avoid all those pitfalls.
 
  • Like
Reactions: tbaror