I followed this link - https://docs.docker.com/engine/api/sdk/examples/ and the docker SDK worked fine while I was using Docker containers. Now that I have moved to K8s, when I run the code I get error like "Container Not Found" . Is there a way to use Python Docker SDK inside of Kubernetes PODS? Error:
docker.errors.NotFound: 404 Client Error for http+docker://localhost/v1.41/containers/taskmanager-son/json: Not Found ("No such container: taskmanager-son")
Note: I am not facing this error while running as Plain Docker Containers. This happens only when code runs inside of k8s PODS.
Note: Also docker ps returns nothing since all containers are running inside K8s PODS
import docker
docker_client = docker.from_env()
print(docker_client.containers.list())
# Returns none since since all containers are running inside K8s PODS
You can refer about Python Docker SDK here: https://docker-py.readthedocs.io/en/stable/