Questions tagged [dockerpy]

The Python API client for Docker

The Python API client for Docker https://github.com/dotcloud/docker-py

191 questions
3
votes
1 answer

Unexpected behavior from docker-py client

I'm trying to run some basic code from the Getting Started documentation (https://docker-py.readthedocs.io/en/stable/index.html#getting-started) for the docker-py package, but am running into problems in both Python 2.7.6 and Python 3.4.3: >>>…
Dave
  • 177
  • 1
  • 7
3
votes
2 answers

Executing shell command using docker-py

I'm trying to run a shell command with docker-py on an already-running container, but get an error: exec: "export": executable file not found in $PATH here's how I wrote the script: exe = client.exec_create(container=my_container, cmd='export…
Mahyar
  • 1,011
  • 2
  • 17
  • 37
3
votes
1 answer

Manipulating network traffic between containers in Docker in Docker environment without privileged mode?

In an environment where docker containers are running inside other docker containers (by mounting the docker socket, not running as privileged), is there any way to manipulate the network to do things like: Introduce latency Drop % of…
enderland
  • 13,825
  • 17
  • 98
  • 152
3
votes
2 answers

Stop docker-py events stream iteration

How can i ask to docker-py events to stop events stream iterable ? I want, for exemple, simply stop to watch dockers events. from docker import Client client = Client(base_url='unix://var/run/docker.sock') events = client.events(decode=True) for…
bux
  • 7,087
  • 11
  • 45
  • 86
3
votes
3 answers

How can I detect when docker-py client.build() fails

I'm using docker-py to build and run Docker images. From reading the documentation it isn't clear to me how I'm supposed to detect if there was an error building the image. build() doesn't raise an exception when there's an error. That makes me…
Tom Hennen
  • 4,746
  • 7
  • 34
  • 45
3
votes
1 answer

Docker output of exec command in detach mode

I'm trying to start a jar file inside a running container. In order to do this I use this command docker exec -t -d [containerID] java -jar jarname.jar. The command is successfully executed but I am unable to see its output. Docker allocates a…
user2419952
  • 31
  • 1
  • 4
3
votes
1 answer

Getting list of running docker containers using docker-py

I'm using docker-py to manage docker containers for one of my apps. I want to retrieve the list of all running containers, identical to docker ps. But the containers method only returns an empty list. >>> import docker >>> c = docker.Client() >>>…
TeknasVaruas
  • 1,480
  • 3
  • 15
  • 28
2
votes
2 answers

How to limit CPU numbers in Docker Client API?

I have a script using docker python library or Docker Client API. I would like to limit each docker container to use only 10cpus (total 30cpus in the instance), but I couldn't find the solution to achieve that. I know in docker, there is --cpus…
WenliL
  • 419
  • 2
  • 14
2
votes
1 answer

dockerpy not able to connect to docker daemon inside bit bucket container

I have the below simple script which is basically to test whether https://github.com/docker/docker-py is able to run commands inside bitbucket containers: import docker CLIENT = docker.DockerClient(base_url="unix://var/run/docker.sock") for image…
Subhayan Bhattacharya
  • 5,407
  • 7
  • 42
  • 60
2
votes
2 answers

docker-py client.images.list() always shows all images

I'm not able to filter images from client.images.list() https://docker-py.readthedocs.io/en/stable/images.html#docker.models.images.ImageCollection.list The documentation says "name (str) – Only show images belonging to the repository…
snakajim
  • 41
  • 1
  • 3
2
votes
0 answers

Starting multiple containers with configs using the Python Docker SDK

I am using the Docker Python SDK docker-py to create a script that allows starting one or multiple containers (depending on a program argument in a way like script.py --all or script.py --specific_container) and it has to be possible to start each…
Manu
  • 284
  • 2
  • 20
2
votes
1 answer

Unable to see container logs from my C++ App when using client.containers.run of docker-py

In python with docker-py, I am running two docker containers: eclipse-mosquitto an ubuntu:bionic based image where my C++ App is launched with ENTRYPOINT ["/directory/myApp"] I use the following docker-py API: container =…
Mike
  • 21
  • 1
2
votes
1 answer

How to get the container ID from docker-py

I'm trying to check whether a docker container is up or not using filter of docker-py module. However able to check whether it is up or down. For reference : def checkDockerContainerStatus( container): client = docker.from_env() cli =…
Aaditya R Krishnan
  • 495
  • 1
  • 10
  • 31
2
votes
1 answer

How to filter docker containers in exited status using docker_host_info?

Is there any other ansible-docker module to capture all the containers on the VM even the ones in exited status. - name: Get container info docker_host_info: containers: yes register: result docker_host_info captures the containers…
Sara James
  • 133
  • 1
  • 14
2
votes
0 answers

[docker-py SDK]: docker service update How to pass "--config-rm" and --config-add options

I am fighting with automating smth with docker SDK for python. All went well until I need to run the following command: docker service update --config-rm "$OLD_CONFIG"\ --config-add…
Sasha
  • 21
  • 2