Answers: <p>As for the tool kind of a thing, I think you're looking for something like <a href="https://github.com/alexei-led/pumba" rel="noreferrer">pumba</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2020-05-22T10:04:41.233Z
Answers: 2020-05-22T10:04:41.233Z
Answers: YoganA
Answers: <p>Just a quick follow-up on <a href="https://github.com/alexei-led/pumba#stress-testing-docker-containers" rel="noreferrer">pumba</a>. Installation (for Ubuntu):</p>
  
  <pre><code>$ curl -SL https://github.com/alexei-led/pumba/releases/download/0.7.2/pumba_linux_amd64 -O
  $ sudo mv pumba_linux_amd64 /usr/bin/pumba
  $ sudo chmod +x /usr/bin/pumba
  $ pumba --version
  </code></pre>
  
  <p>It uses <a href="https://wiki.ubuntu.com/Kernel/Reference/stress-ng" rel="noreferrer">stress-ng</a> under the hood, so same commands apply. Examples: </p>
  
  <ol>
  <li><pre><code>$ pumba stress -d 1m container_name
  </code></pre>
  
  <p><code>-d 1m</code> - duration of a stress test (1 minute)</p>
  
  <p><code>container_name</code> - your target container (from <code>docker ps</code> output)</p></li>
  <li><pre><code>$ pumba stress -d 30s --stressors "--vm 10 --vm-bytes 512M --vm-hang 20" container_name
  </code></pre>
  
  <p><code>-d 30</code> - duration 30 seconds</p>
  
  <p><code>-stressors</code> - parameters passed to <em>stress-ng</em> app</p>
  
  <p>In this particular example we create 10 workers spinning on <em>malloc()/free()</em> allocating <code>512MB</code> each and sleep 20 seconds before freeing the memory.</p></li>
  </ol>
  
  <p>Default stressor as in first example is <code>--cpu 4 --timeout 60s</code></p>
  
Answers: CC BY-SA 4.0
Answers: 2020-05-27T07:46:58.663Z
Answers: 2020-05-27T07:46:58.663Z
Answers: Most Wanted
Body: <p>I want my container to die under high pressure to check monitoring and alerting as well as compose autorestarts. What is best way to simulate heavy load within docker container. I've tried so far</p>
  
  <pre><code>root@docker-vm:/# stress --vm 10 --vm-bytes 2048M --vm-hang 20
  stress: info: [238] dispatching hogs: 0 cpu, 0 io, 10 vm, 0 hdd
  stress: FAIL: [238] (415) &lt;-- worker 243 got signal 9
  stress: WARN: [238] (417) now reaping child worker processes
  stress: FAIL: [238] (451) failed run completed in 101s
  
  </code></pre>
  
  <p>for memory pressure (hoping OOM kill for host machine which has 4Gb of ram) and <code>stress --cpu 100</code> which is obviously not really harmful.</p>
  
  <p>Is there some tool to achieve that for docker or preferred approach I should use?</p>
  
Tags: <docker><docker-compose><containers>
Title: Stress testing for docker container
UserDisplayName: Most Wanted
ThreadText: # Stress testing for docker container
  
  (Asked by: username_0 on 2020-05-22)
  
  I want my container to die under high pressure to check monitoring and alerting as well as compose autorestarts. What is best way to simulate heavy load within docker container. I've tried so far
  
  ```
  root@docker-vm:/# stress --vm 10 --vm-bytes 2048M --vm-hang 20
  stress: info: [238] dispatching hogs: 0 cpu, 0 io, 10 vm, 0 hdd
  stress: FAIL: [238] (415) <-- worker 243 got signal 9
  stress: WARN: [238] (417) now reaping child worker processes
  stress: FAIL: [238] (451) failed run completed in 101s
  
  ```
  
  for memory pressure (hoping OOM kill for host machine which has 4Gb of ram) and `stress --cpu 100` which is obviously not really harmful.
  
  Is there some tool to achieve that for docker or preferred approach I should use?
  
  **Tags:** docker, docker-compose, containers
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_0 on 2020-05-27. Score: 7 | Accepted answer
  
  Just a quick follow-up on [pumba](https://github.com/alexei-led/pumba#stress-testing-docker-containers). Installation (for Ubuntu):
  
  ```
  $ curl -SL https://github.com/alexei-led/pumba/releases/download/0.7.2/pumba_linux_amd64 -O
  $ sudo mv pumba_linux_amd64 /usr/bin/pumba
  $ sudo chmod +x /usr/bin/pumba
  $ pumba --version
  
  ```
  
  It uses [stress-ng](https://wiki.ubuntu.com/Kernel/Reference/stress-ng) under the hood, so same commands apply. Examples:
  
  1. ```
     $ pumba stress -d 1m container_name
  
     ```
  
     `-d 1m` - duration of a stress test (1 minute)
  
     `container_name` - your target container (from `docker ps` output)
  2. ```
     $ pumba stress -d 30s --stressors "--vm 10 --vm-bytes 512M --vm-hang 20" container_name
  
     ```
  
     `-d 30` - duration 30 seconds
  
     `-stressors` - parameters passed to *stress-ng* app
  
     In this particular example we create 10 workers spinning on *malloc()/free()* allocating `512MB` each and sleep 20 seconds before freeing the memory.
  
  Default stressor as in first example is `--cpu 4 --timeout 60s`
  
  
  ---
  
  ### Answer by username_1 on 2020-05-22. Score: 5
  
  As for the tool kind of a thing, I think you're looking for something like [pumba](https://github.com/alexei-led/pumba)
  
  
  ---
  
  