Docker Compose IP Range: Not Accessing Deluge via Mac VLAN (192.168.100.40-49)
Docker Compose is a powerful tool for defining and running multi-container Docker applications. It allows you to define a multi-container application in a YAML file, and then spin up all the containers with a single command. In this article, we will explore how to use Docker Compose to create a network with a specific IP range, and how to ensure that Deluge is not accessible via a Mac VLAN within that range.
Defining a Docker Compose Network with a Specific IP Range
To define a Docker Compose network with a specific IP range, you can use the networks section of your docker-compose.yml file. Here is an example:
version: '3'
services:
web:
image: nginx:latest
networks:
mynetwork:
ipv4\_address: 192.168.100.40
networks:
mynetwork:
driver: bridge
ipam:
config:
- subnet: 192.168.100.0/24
In this example, we have defined a network called mynetwork with a subnet of 192.168.100.0/24. We have also specified that the web service should have an IP address of 192.168.100.40 within this network.
Preventing Access to Deluge via a Mac VLAN
If you are running Docker on a Mac, you may encounter issues with accessing services within your Docker network via the Mac's VLAN. In particular, you may find that Deluge is accessible via the Mac's VLAN even if it is not explicitly exposed. To prevent this, you can use the mac_address option in your docker-compose.yml file to specify a unique MAC address for the Deluge container. Here is an example:
version: '3'
services:
deluge:
image: linuxserver/deluge
mac_address: 00:11:22:33:44:55
networks:
mynetwork:
ipv4\_address: 192.168.100.41
networks:
mynetwork:
driver: bridge
ipam:
config:
- subnet: 192.168.100.0/24
In this example, we have specified a unique MAC address for the Deluge container using the mac\_address option. This will prevent the Deluge container from being accessible via the Mac's VLAN.
Testing Your Setup
To test your setup, you can use the docker-compose up command to spin up all the containers in your network. Once the containers are running, you can use the docker network inspect command to view the IP addresses and MAC addresses of the containers in your network. Here is an example:
$ docker network inspect mynetwork
[
{
"Name": "mynetwork",
"Id": "e8f4c8c9e1b6d68e1f9f9b5a8f0e6e1a7f1c8f7e1e2c2f2f2f2f2f2f2f2f2f2f",
"Created": "2023-03-13T16:22:01.2981124Z",
"Scope": "local",
"Driver": "bridge",
"EnableIPv6": false,
"IPAM": {
"Driver": "default",
"Options": null,
"Config": [
{
"Subnet": "192.168.100.0/24"
}
]
},
"Internal": false,
"Attachable": false,
"Ingress": false,
"ConfigFrom": {
"Network": ""
},
"ConfigOnly": false,
"Containers": {
"d
```