DEV Community

Dimitrios Desyllas
Dimitrios Desyllas

Posted on

Why running a container via docker sdk in python I get different output compared to the actual command line?

I try to interface docker using python:

In a shell session I have run:

 docker run --rm --net host busybox /bin/sh -c "ip route get 1 | sed -n 's/^.*src \([0-9.]*\) .*$/\1/p'"

The output of the command is:

10.0.2.15

But for a utility script that interfaces docker directly using python and docker-sdk I run the same command…

But it seems that I fail to get same output from the one I cat from docker-cli. Can u help me?

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more