Can't open an interactive container
See original GitHub issueI’m trying to convert a Python script from executing command line statements to using docker-py. I have a running container with MongoDB, and I want to create another container with Mongo shell.
This command-line works for me as expected:
docker run -i -t --entrypoint="mongo" mongo-image mongo-url:27017
Also succeeded converting it to separate docker create
, docker start
and docker attach
commands, but I fail to get an interactive Mongo shell using docker-py. This is what I’m trying to do:
container = c.create_container(
image=MONGO_IMAGE,
entrypoint='mongo',
command='%s:27017' % ip,
detach=False,
stdin_open=True,
tty=True
)
c.start(container=container['Id'])
c.attach(container=container['Id'])
but it doesn’t work (container is created, but not attached). How can I make it happen?
Issue Analytics
- State:
- Created 9 years ago
- Comments:9
Top Results From Across the Web
cannot start interactive shell with docker container
Yes docker start command should start the container, but there are some questions around here, is your container running a one-time process or ......
Read more >Debugging docker container that won't start | by suprit shah
I will show you how to start docker container in a debug mode (interactive shell) and dive deep into investigating docker-entrypoint.sh ...
Read more >Unable to run docker in Interactive mode - General Discussions
I was trying to run docker in interactive mode where i could login to the container. I switched to root user then I...
Read more >How to Launch a Docker Container with an Interactive Shell
When you start a container from the Base image using Docker, Docker fetches ... running under Nginx Web Server using an interactive shell...
Read more >Interactive Container - am I missing something?
Interactive Container - I have selected interactive content but I cannot select "Insert PDF" from the context menu - am I missing something?...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
my run command looks like this:
you just need to check those first lines about stdin_open and tty
please note that the container does not become interactive within the python terminal, it just means that i can attach to the container later (this is what i want). if you want to attach to the container, then i would suggest using a system command to docker to perform this for you. trying to do this from within python sounds very messy, as the remote terminal should essentially have full control of the local terminal, which would mean a lot of actions would have to be passed through python, and the docker executable would do a much more consistent job of this.