Doing `ip` commands during docker build

Hi all,
I’m creating a docker compose with 3 containers
I want to change the default ip route of a container during the build stage, but I get an error.
Do I have to change the ip route after the container has started in the ENTRYPOINT?

FROM debian:latest

WORKDIR /app

RUN apt-get update && apt-get install -y \
    iproute2 \
    iptables \
    tcpdump \
    dnsutils \
    neovim

# Copy the custom shell script into the container
COPY stage5/client.sh /app/client.sh

# Make the script executable
RUN chmod +x /app/client.sh

CMD ["sh", "-c", "/app/client.sh"]
#!/bin/sh

# Remove the default route
ip route del default

# Add a new route to 192.168.1.30 via 192.168.1.20
ip route add default via 192.168.1.20

# Test DNS resolution by querying www.example.com
dig @192.168.1.30 www.example.com

# Keep the script running indefinitely (equivalent to 'tail -f /dev/null')
tail -f /dev/null

services:
  client:
    image: ubuntu:latest
    build:
      context: ../
      dockerfile: stage5/Dockerfile.client
    cap_add:
      - NET_ADMIN # Required for iptables or routing
      - SYS_ADMIN
      - NET_RAW
    depends_on:
      - gateway
    networks:
      client-network:
        ipv4_address: 192.168.1.10

  bind9:
    container_name: dns-auth-srv-stage5
    image: ubuntu/bind9:latest
    environment:
      - BIND9_USER=root
      - TZ=Europe/Jerusalem
    ports:
      - "127.0.0.1:53:53/tcp"
      - "127.0.0.1:53:53/udp"
    networks:
      dns-network:
        ipv4_address: 192.168.2.30

  gateway:
    build:
      context: ../
      dockerfile: stage5/Dockerfile.gateway
    networks:
      client-network:
        ipv4_address: 192.168.1.20
      dns-network:
        ipv4_address: 192.168.2.20
    cap_add:
      - NET_ADMIN # Required for iptables or routing
      - SYS_ADMIN
      - NET_RAW
    privileged: true # Needed for network operations

networks:
  client-network:
    driver: bridge
    ipam:
      config:
        - subnet: 192.168.1.0/24
  dns-network:
    driver: bridge
    ipam:
      config:
        - subnet: 192.168.2.0/24