Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker-tc fails with multiple containers in same network #2

Open
Silcet opened this issue Jul 18, 2019 · 11 comments
Open

Docker-tc fails with multiple containers in same network #2

Silcet opened this issue Jul 18, 2019 · 11 comments
Assignees
Labels
bug Something isn't working

Comments

@Silcet
Copy link
Contributor

Silcet commented Jul 18, 2019

When a new container is started, docker-tc finds out the network device of the container without any issue and everything works. When a second container is started in the same network, the docker_network_get_interface() function returns both network devices separated by a space. This return value makes any other function that tries to use it fail.
Test with 2 busybox containers pinging google.com:

$ NETWORK_ID=$(docker network inspect --format '{{ .Id }}' "test-net")
$ echo $NETWORK_ID
b8c595e522ccdfbd75be7543eaa214f97603274a79e3f1d86269fb59ddd627c8
$ SHORT_NETWORK_ID=$(echo -n "$NETWORK_ID" | head -c 12)
$ echo $SHORT_NETWORK_ID
b8c595e522cc
$ NETWORK_INTERFACE_NAME=$(ip a | grep -E "veth.*br-$SHORT_NETWORK_ID" | grep -o 'veth[^@]*' || :)
$ echo $NETWORK_INTERFACE_NAME
veth756b15f vethcea04c9
@Silcet
Copy link
Contributor Author

Silcet commented Jul 18, 2019

@lukaszlach I believe I already have a fix for it and I have already forked the repo. I'll try to fix it myself and if you like the solution I can make a pull request ;)

@zzhou612
Copy link

Confirmed. If multiple docker containers are connected to the same bridge network, then the current workflow will fail to work.

Docker Container → Docker Network ID → Linux Network Interface

For a single bridge network, each container that links to it will have a veth interface. So the bash script will return multiple items for NETWORK_INTERFACE_NAME.

@zzhou612
Copy link

zzhou612 commented Sep 19, 2019

It seems that matching Docker Container ID with veth is not that trivial. There are some open-sourced scripts doing this: https://github.com/micahculpepper/dockerveth.

@Silcet
Copy link
Contributor Author

Silcet commented Sep 19, 2019

I have a fix for it already in my fork. I just need to get my branch and commits cleaned up and I'll make a pull request ;)

@zzhou612
Copy link

Thank you. I saw your implementation. But https://github.com/micahculpepper/dockerveth points out:

When I'm tracking down a problem in production, I'll typically wind up on a Docker server and see that my problems are coming from one veth interface or another. But making the leap from veth ID to container ID can be tricky. Folks on the internet suggest that you run some commands in bash inside your container, which is OK if your container has bash. Sometimes I'm working on Go containers that are just a single binary and don't even have a command-line interface to attach to.

I wish that I could make the leap from container ID to veth ID without provoking sudo privileges. But it seems that it is hard to do so with out sudo.

@Lawouach
Copy link

Lawouach commented Nov 4, 2019

Hello folks, I am interested in using this tool too and was wondering if there was a chance for a release with the fix @Silcet? Thanks :)

@lukaszlach lukaszlach self-assigned this Nov 4, 2019
@lukaszlach lukaszlach added bug Something isn't working help wanted Extra attention is needed labels Nov 4, 2019
@Silcet
Copy link
Contributor Author

Silcet commented Nov 14, 2019

@Lawouach I just need to clean my commits to make a branch for the pull request. I'll try to get it done today. Sorry for the wait ;)

@Lawouach
Copy link

No worries. Always appreciated to have feedback :)

@Silcet
Copy link
Contributor Author

Silcet commented Nov 15, 2019

Ok, I have just made the pull request #5 . @Lawouach maybe you could try to test it to see if it feets your needs?

@Lawouach
Copy link

Awesome. Your branch seems to be working just fine @Silcet!

@lukaszlach
Copy link
Owner

lukaszlach commented Nov 19, 2019

Can I ask you to confirm that the #5 just merged resolves this issue?
The updated Docker image has also been released on Docker Hub.

@lukaszlach lukaszlach removed the help wanted Extra attention is needed label Nov 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants