How can I rate limit network traffic on a docker container

I want to setup a docker container for a peer 2 peer app. This app doesn’t have app level rate limiting so I’m attempting to set a limit at the container level. I would like to rate limit outgoing and incoming connections on all ports but the one used by the app’s web UI.

  • Add Docker Container IP to Host Machine /etc/host
  • Docker compose hangs when installing kerberos
  • HTTP 504 Gateway Time-out when serving static file with Django (Nginx + Gunicorn)
  • Fallback for environment variables with docker-compose
  • `docker attach` command can't enter into a container unless Ctrl+C or Enter pressed
  • How to pass supervisor an environment variable from the docker run command
  • docker-machine create error … VBoxManage: error: Unknown option: --synthcpu
  • org.jolokia:docker-maven-plugin:0.10.4:push (code: 500, Internal Server Error)
  • How do I set rack and datacenter name for scylladb using docker?
  • Docker tmpfs volume and increasing size
  • Unable to clean up <none> repository
  • How to ssh to a docker container on ec2 ubuntu host from outside machine
  • One Solution collect form web for “How can I rate limit network traffic on a docker container”

    You could use the iptables limits module. For example, you could add a rule to the PREROUTING table using the options “-m limit –limit 10/s” to limit a particular port to receive only 10 connections per second.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.