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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more