Skip to main content

Getting started

Before we continue, make sure you have a recent version of docker installed and setup correctly. For a step-by-step guide see here.

Changing the default ip range

Depending on your home network setup, the default ip range for docker networks might conflict with the ip range in your home network. To avoid conflicts we can change the default ip range that docker uses. Since docker uses the subnet 172.17.0.0/16 for their default bridge network, we need to avoid it. We can use a different one like 172.42.0.0/16 for example.

  1. Create or edit the config file for the docker daemon:
    sudo nano /etc/docker/daemon.json
    
  2. Add the following using your
    {
      "default-address-pools":
      [
        {"base":"172.42.0.0/16","size":24}
      ]
    }
    
    This will make docker use subnets like 172.42.1.0/24 or 172.42.2.0/24 whenever a new network is created.
  3. Restart the docker service to apply the changes
    service docker restart
    
  4. When you already have some docker networks, simply docker compose down the corresponding containers and use docker network rm <<networkname>> to remove the network. The next time you start up the containers, docker will automatically recreate the network with the correct settings.

You can also manually define the subnet used for a given network from inside a compose file. It could look like this:

networks:
  default:
    name: "network_name"
    ipam:
      driver: default
      config:
        - subnet: "172.42.10.0/24"

See also