0

I'm using docker python SDK docker-py, which is quite convenient. I look through the document, I still can't figure out how to create a daemon container with interface terminal,that is to say, if in the shell, this equals to the command docker run -dit image.

I know docker-py right now offers the client.containers.run to run a contaniner, and with deatch argument I can run it as a daemon. However, I want start it with a interface terminal.

'Cause my further code would access to the container from the remote server. Is there any way to create it directly with docker-py instead of using os.system(docker run -dit image)?

ucag
  • 275
  • 1
  • 6
  • 20
  • Like `docker run`, [`client.containers.run` has many options](https://docker-py.readthedocs.io/en/stable/containers.html). Those should correspond to all of the `docker run` command-line options. – David Maze Aug 25 '18 at 11:03

1 Answers1

0

After swimming in the doc for a while, I figure it out. The command docker run -dit image in docker-py is client.containers.run(image,tty=True,stdin_open=True, detach=True) This would work. Thank u David.

ucag
  • 275
  • 1
  • 6
  • 20