question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

prompt doesn't show in docker image (2.0 branch)

See original GitHub issue

I was trying to run my application on a python docker container but the prompt is not shown. Here is a simple way to reproduce it.

docker pull python
docker run --name python -dit python
docker exec -it python /bin/bash

then in the container, install prompt_toolkit

pip install git+https://github.com/jonathanslenders/python-prompt-toolkit

a simple script test.py

from prompt_toolkit import prompt

print("enter something")
text = prompt("> ")
print("you entered %s." % text)

run the script and enter “foo”

root@2084abd7fdb1:/# python test.py
enter something
you entered foo.

Note that the prompt was not shown in above. Interestingly, it works again if I reset the terminal

root@2084abd7fdb1:/# reset
root@2084abd7fdb1:/# python test.py
enter something
> bar
you entered bar.

BTW, I am using macOS iTerm if it matters.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
randy3kcommented, Jun 8, 2018

I found a hacky solution from stackoverflow

docker exec -it python bash -c "stty cols $COLUMNS rows $LINES && bash"
0reactions
randy3kcommented, Jul 10, 2018

I think prompt toolkit should nevertheless be able to handle the case of tty not getting the terminal size correctly.

Read more comments on GitHub >

github_iconTop Results From Across the Web

prompt doesn't show in docker image (2.0 branch) #625 - GitHub
I was trying to run my application on a python docker container but the prompt is not shown. Here is a simple way...
Read more >
Add git branch name on bash command prompt in docker ...
I add the same code to docker container ~/.bashrc when making docker image. However, it only colored the current directory but not showing...
Read more >
docker image pull
docker image pull: Pull an image or a repository from a registry.
Read more >
Developing inside a Container - Visual Studio Code
Developing inside a Container. The Visual Studio Code Dev Containers extension lets you use a Docker container as a full-featured development environment.
Read more >
Docker@2 - Docker v2 task - Microsoft Learn
Build or push Docker images, login or logout, start or stop containers, or run a Docker command.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found