Using Pumba to shutdown the container connection permanently

371 Views Asked by At

I am trying to use Pumba to isolate a container from the docker network. I am on Windows, and the command I am using is the following.

 docker run \
   -d \
   --name pumba \
   --network docker_default \
   -v //var/run/docker.sock:/var/run/docker.sock 
   gaiaadm/pumba netem \
   --tc-image="gaiadocker/iproute2" \
   --duration 1000s \
   loss \
   -p 100 \
   753_mycontainer_1

I start the container to isolate using docker-compose, with the restart property set to always. My wish is to let Pumba block the networking of the container also after each restart.

How can I achieve this behavior?

Thanks.

1

There are 1 best solutions below

0
On BEST ANSWER

I managed to achieve the result, letting the docker restart the pumba container. I reduce the duration parameter to 30s that is the average time for my 753_mycontainer_1 container to stop itself and restart.

In this way, the two containers restart more or less synchronously, producing a real chaos test, in which the 753_mycontainer_1 container randomly lose the network.

docker run \
  -d \
  --name pumba \
  --restart always \
  --network docker_default \
  -v //var/run/docker.sock:/var/run/docker.sock gaiaadm/pumba \
  netem \
  --tc-image="gaiadocker/iproute2" \
  --duration 30s \
  loss \
  -p 100 \
  753_mycontainer_1