Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to capture packets for single docker container

There have many container running on the host. And I want to capture packets for the one container of these. Is there any way to do this?

like image 708
sope Avatar asked Sep 07 '16 06:09

sope


People also ask

Can a single container have multiple images?

Can we have a single container with multiple image like nginx + Redis + alpine ? You can have multiple processes inside a container but it wouldn't really be a best practice. Having NGINX and Redis in separate containers but inside the same pod would be better.

Can one container run multiple services?

It's ok to have multiple processes, but to get the most benefit out of Docker, avoid one container being responsible for multiple aspects of your overall application. You can connect multiple containers using user-defined networks and shared volumes.

Can one Docker container run multiple images?

In later versions of Docker, it provides the use of multi-stage dockerfiles. Using multi-stage dockerfiles, you can use several base images as well as previous intermediate image layers to build a new image layer.


1 Answers

You can bind to the network namespace of one container to another:

docker run -it --rm --net container:<container_name> \   nicolaka/netshoot tcpdump ... 

To see more about the netshoot image used above, see: https://github.com/nicolaka/netshoot

like image 124
BMitch Avatar answered Sep 17 '22 15:09

BMitch