I’m having trouble configuring Docker networking on my Ubuntu 24.04 host, and I could really use some help.
Environment:
- Host OS: Ubuntu 24.04
- Host IP: 10.78.20.20 (running on an ESXi machine)
- Docker is installed and running fine.
- I am new to Docker.
I can successfully run a Docker container and access it through the host IP (10.78.20.20). However, I want to assign a different IP to this container, such as 10.78.20.40.
Here is a snippet from my docker-compose.yml where I attempted to set up a custom bridge network:
networks:
custom_bridge:
driver: bridge
ipam:
config:
- subnet: 10.78.20.0/24
gateway: 10.78.20.1
services:
my_service:
image: my_image
networks:
custom_bridge:
ipv4_address: 10.78.20.40
Unfortunately, this configuration didn’t work as expected. The container is still not accessible via the new IP address.
I tried several other guides and tutorials from the internet, but none of them solved my issue.
Question:
How can I properly configure Docker to assign a specific IP address (10.78.20.40) to my container on my current setup?
Any help or guidance would be greatly appreciated!
2