Questions tagged [dockerpy]

The Python API client for Docker

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

191 questions
2
votes
2 answers

python docker sdk how to run multiple commands in containers.run

I am using python 3 with docker sdk and using containers.run in order to create a container and run my code when I use command argument with one command as a string it works fine see code client = docker.from_env() container =…
thebeancounter
  • 4,261
  • 8
  • 61
  • 109
2
votes
1 answer

standard_init_linux.go:211:exec user process caused "no such file or directory" with alpine linux and python

I have a directory which contains the docker file, a attack.py and a requirements.txt. Using that, I created the following dockerfile: FROM arm64v8/python:3.7-alpine COPY qemu-arm-static /usr/bin COPY ./ app-ids WORKDIR /app-ids RUN pip install…
Druckermann
  • 681
  • 2
  • 11
  • 31
2
votes
1 answer

docker container in detach mode exits instantly

I am using docker SDK for python and trying to create a container. Following is the code I am executing: import docker client = docker.DockerClient(base_url='tcp://10.41.70.76:2375') image = client.images.get('siab_user_one') container =…
Aditya
  • 551
  • 5
  • 26
2
votes
0 answers

python docker apis is it possible to create a container and just run a command?

I want to create a container and then run a command. Is this possible using python docker apis ? I was able to create the container but I was not sure how to run a command inside that container.. does anybody know ? if I use run , it creates another…
user2511126
  • 620
  • 1
  • 14
  • 31
2
votes
1 answer

Run docker container with image name docker-py

I want to be able to run my docker container from inside docker-py, but when I pass a name to the function it gives me an error. Stripped down version of my code: image = "test_container" client.containers.run(image=image) Error: File…
Connor
  • 4,216
  • 2
  • 29
  • 40
2
votes
1 answer

How can I get the host ip in a docker container using Python?

Context: I implemented tests which use docker-py to create docker networks and run docker containers. The test runner used to execute the tests is pytest. The test setup depends on Python (Python package on my dev machine), on my dev machines docker…
thinwybk
  • 4,193
  • 2
  • 40
  • 76
2
votes
1 answer

how to assign-static-ip-to-docker-container in docker-py

I think I know how to assign a static ip in docker. Something like this seems to work: docker run -it --rm --net=br0 --cap-add=NET_ADMIN --ip=172.27.153.11 mbussim The problem is doing this in docker-py, which I think is just a python docker…
2
votes
1 answer

Docker container RestartCount not incrementing

Test def test_can_pop_new_container(self): config = { 'ip': '10.49.0.2', 'subnet': '10.49.0.0/16', 'gateway': '10.49.0.202', 'vlan': 102, 'hostname': 'test-container', } container =…
Édouard Lopez
  • 40,270
  • 28
  • 126
  • 178
2
votes
1 answer

running and sharing a host folder from a container using docker-py

I want to run a container using the python docker with a persistent shared folder. The command line to do so is as follow : docker run --rm -ti -v /home/docker:/container_shared_folder ubuntu:14.04 bash -c my_command can you please help me to…
Mounirsky
  • 117
  • 7
2
votes
1 answer

Dockerpy executing command to cat log file

This seems simple, but I am trying to replicate the following Docker command using Docker-py: docker exec dockerName cat /var/log/foo.log Using dockerpy, it seems the following should work: from docker.client import Client from docker.utils import…
enderland
  • 13,825
  • 17
  • 98
  • 152
2
votes
0 answers

piping data to exec_create & stdin/stdout

I've re-written this question to better communicate what I'm trying to achieve. If I use the docker CL this works perfectly for me. echo "hello" | docker exec -i $3 sh -c 'cat >/text.txt' Now I want to use docker-py and have this so far: ex =…
user1513388
  • 7,165
  • 14
  • 69
  • 111
2
votes
2 answers

docker-py exec_start howto stream the output to stdout

I'm trying to execute some long processes with docker-py My problem is that I'm not able to see the output of what I'm doing... How can I stream the output from the docker exec directly to stdout ? or better to logging ? I've seen there is a…
OpenStove
  • 714
  • 1
  • 11
  • 22
2
votes
2 answers

how to bind ports with docker-py

I try to start a docker container with docker-py (Version 1.3.1). I want to map the container internal ports to different ports but fail to expose them properly. I do this like so: def start_container(client, host_config, image_tagged_name,…
Udo Klein
  • 6,784
  • 1
  • 36
  • 61
2
votes
1 answer

Why would inspect.getfile give me a file that's not there?

Or, Saltstack + docker-py AttributeError: 'RecentlyUsedContainer' object has no attribute 'lock' I have been digging into this issue to no avail. I'm trying to use SaltStack to manage my docker images/containers but ran into this problem. Initially…
Wayne Werner
  • 49,299
  • 29
  • 200
  • 290
2
votes
2 answers

Ansible Shell Cannot Pull Docker Image

I've run into issues pulling Docker images from a private DockerHub repo using the Docker module of Ansible, so to sanity-check that code decided to try pulling the image in question first using the shell. This also fails. What's going on here? If I…
Alex Lynham
  • 1,318
  • 2
  • 11
  • 29