I have created a custom network by using command:
docker network create --driver=bridge --subnet=192.168.1.0/16 --gateway=192.168.1.1 -o "com.docker.network.bridge.host_binding_ipv4"="0.0.0.0" -o "com.docker.network.bridge.enable_icc"="true" -o "com.docker.network.bridge.enable_ip_masquerade"="true" my-net
Post creation I have created docker containers using docker compose:
version: "3"
services:
web:
build: './UI'
ports:
- "80:80"
tty: true
links:
- service
networks:
my-net:
ipv4_address: 192.168.1.2
service:
build: './Service'
ports:
- "8090:8090"
tty: true
networks:
my-net:
ipv4_address: 192.168.1.3
networks:
my-net:
external:
name: my-net
Now when I am pinging the containers internally, I am getting the response. But when I am trying pinging google.com, container is unable to ping it.
I also ran this command, but no success.
sysctl net.ipv4.conf.all.forwarding=1