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)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay