Questions tagged [dockerpy]

The Python API client for Docker

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

191 questions
35
votes
2 answers

Capturing output of python script run inside a docker container

The aim here is to use a docker container as a secure sandbox to run untrusted python scripts in, but to do so from within python using the docker-py module, and be able to capture the output of that script. I'm running a python script foo.py…
acr
  • 531
  • 1
  • 8
  • 8
28
votes
1 answer

pipeline in docker exec from command line and from python api

What I try to implement is invoking mysqldump in container and dump the database into the container's own directory. At first I try command below: $ docker exec container-name mysqldump [options] database | xz > database.sql.xz That's not working,…
pingz
  • 555
  • 1
  • 10
  • 20
17
votes
2 answers

How to send to stdin of a docker-py container?

Considering this shell example: echo "hello" | docker run --rm -ti -a stdin busybox \ /bin/sh -c "cat - >/out" This will execute a busybox container and create a new file /out with the contents hello. How would I accomplish this with docker-py…
itsafire
  • 5,607
  • 3
  • 37
  • 48
16
votes
3 answers

How to copy a file from host to container using docker-py (docker SDK)

I know, there is possible way how to copy file bidirectionally between host and docker container using docker cp and also it is possible to obtain file from running container using docker-py. But I am not able to figure out how (or if it is even…
s.t.e.a.l.t.h
  • 440
  • 2
  • 4
  • 14
10
votes
2 answers

Docker remote api pull from Docker hub private registry

I'm trying to pull docker images from a private repository hosted in Docker hub https://registry.hub.docker.com/u/myname/myapp like this using the docker remote API. The doc is not clear as to how to specify the authentication credentials in a POST…
alpha_cod
  • 1,933
  • 5
  • 25
  • 43
10
votes
1 answer

How to use docker-py (official docker client) to start a bash shell?

I'm trying to use docker-py to run a docker container and drop me into a bash shell in that container. I get as far as running the container (I can see it with docker ps, and I can attach to it just fine with the native docker client), but when I…
d11wtq
  • 34,788
  • 19
  • 120
  • 195
9
votes
1 answer

docker-py: How to bind an IP address to a container

Say I have a network called "mynet" and I want to start a container with an IP address bound to 192.168.23.2. The code I'm starting with is: import docker c = docker.from_env() c.containers.run('containername', 'sh some_script.sh',…
markzz
  • 1,185
  • 11
  • 23
8
votes
1 answer

docker-py: How to get exit code returned by process running inside container?

My python script uses docker-py to launch a docker container as follows: client = docker.from_env() result = client.containers.run( image="my-prog-image:latest", command=["/etc/my-prog/configs.ini"], auto_remove=True, …
duong_dajgja
  • 4,196
  • 1
  • 38
  • 65
8
votes
1 answer

Docker inside docker : volume is mounted, but empty

I am running a docker container with docker mounted inside using : docker run -v /Path/to/service:/src/service -v /var/run/docker.sock:/var/run/docker.sock --net=host image-name python run.py This runs a python script that creates a data folder in…
user6403833
  • 269
  • 5
  • 13
8
votes
3 answers

How to bind volumes in docker-py?

I think this used to work up to a few months ago. The regular commandline docker: >> docker run --name 'mycontainer' -d -v '/new' ubuntu /bin/bash -c 'touch /new/hello.txt' >> docker run --volumes-from mycontainer ubuntu /bin/bash -c 'ls new' >>…
Jasper van den Bosch
  • 3,169
  • 4
  • 32
  • 55
7
votes
0 answers

Bidirectional communication with 'docker exec -it bash ' using docker-py

I can't seem to figure out how to enable async i/o with a container shell session using docker-py SDK. What I am essentially trying to achieve is to have a working equivalent of docker exec -it bash $container_id in docker-py. Obviously, stdout…
bigpapa
  • 71
  • 5
7
votes
2 answers

Python docker-py Connection Refused

I am having trouble accessing docker daemon from a client using docker-py in Python. I started a docker daemon by the command sudo docker -d & and the output was [1] 4894. Then I tried to access the daemon from python using the code that I got from…
JackOrJones
  • 304
  • 1
  • 6
  • 15
6
votes
2 answers

docker-py : PermissionError(13)

While I was running >>> import docker >>> client = docker.from_env() >>> client.containers.list() I encountered the following error requests.exceptions.ConnectionError: ('Connection aborted.', PermissionError(13, 'Permission denied')) I think it…
Shubham Pandey
  • 83
  • 1
  • 1
  • 5
6
votes
2 answers

Is there a docker inspect in docker python apis?

I would like to get the ipaddress of the containers and I trying to figure out how using python docker APIs. Something like this I would like to do it in python APIs docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}'…
user2511126
  • 620
  • 1
  • 14
  • 31
6
votes
2 answers

Logging in to ecr registry with python docker sdk doesn't work as expected

Assuming I have gotten the ecr credentials from boto already in an object called creds, when I do: client = from_env() client.login(creds.username, password=creds.password, registry=creds.endpoint) I get: {u'IdentityToken': u'', u'Status': u'Login…
Sirrah
  • 1,681
  • 3
  • 21
  • 34
1
2 3
12 13