Docker Community Forums

Share and learn in the Docker community.

Facing issue with docker creation to send layer 2 packet from docker to outer world

My requirement is to send scapy layer 2 packet from docker to outer world.
Docker will be installed in a host linux machine.

For the same, I have used below command to send packet:-
The problem is if I am using port mapping and --network host docker is starting and stopped whithin 3 seconds. Below is the command
sudo docker run -itd -p 30022:22 -p 36901:6901 -p 35901:5901 --privileged --network host --name <docker_name> <image_name>

The reason for port mapping is to run multiple container in single host with vnc and no vnc and ssh.
The reason for --network host is to replicate host machine’s ethernet interfaces in docker container to send scapy layer 2 packet to outer world.

Host machine info :- 4.15.0-54-generic #58~16.04.1-Ubuntu x86_64
container info :- 4.15.0-54-generic #58~16.04.1-Ubuntu x86_64

You might want to dig deeper into host networking and how it actualy works.

Did you check docker ps -a -f name=<docker_name> --no-trunc and docker logs $(docker ps -qa -f name=<docker_name>) for further details about why the container stopped?