Cannot access the internet from within a docker container when using pihole as a DNS

I solved the problem. Now the docker-compose for the PiHole looks like this:

cat docker-compose.yaml
services:
 main:
  image: pihole/pihole:latest
  restart: unless-stopped
  ports:
   - 192.168.1.99:53:53/tcp
   - 192.168.1.99:53:53/udp
  dns:
   - 8.8.8.8
   - 8.8.4.4
  cap_add:
   - NET_ADMIN
  volumes:
   - /etc/timezone:/etc/timezone:ro
   - ./storage/etc/dnsmasq.d:/etc/dnsmasq.d
   - ./storage/etc/pihole:/etc/pihole
  environment:
   - TZ=Europe/Bucharest
   - DNSMASQ_LISTENING=all
   - FTLCONF_LOCAL_IPV4=192.168.1.99
   - VIRTUAL_HOST=pi.hole
   - HOSTNAME=pi.hole
   - PROXY_LOCATION=pi.hole
  networks:
   - traefik_default
  labels:
   - traefik.enable=true
   - traefik.http.routers.pihole.entrypoints=web
   - traefik.http.routers.pihole.rule=Host(`pihole.rpi`)
   - traefik.http.services.pihole.loadbalancer.server.port=80
networks:
 traefik_default:
  external: true

I had to add the IP address when specifying the ports