2

The command promp after running docker exec -it ... bash is not formatted nicely. The problem happens on the OSX terminal or iTerm2. Any setting for the iTerm2 I need to change or is that related to the bash command? Thanks.

Picture:enter image description here

mkasberg
  • 16,022
  • 3
  • 42
  • 46
Kei Yip
  • 45
  • 1
  • 5

1 Answers1

2

I think I can tell from the picture that you're not actually talking about docker logs (which is a docker real docker command that you didn't run). It looks like you want to know why your console output is not printing with nice formatting after you get to a command prompt inside a container with docker exec -it ... bash.

I suspect your PS1 length is being calculated incorrectly either inside the container or on your host machine. Read about it here. The prompt inside the container looks like the standard prompt and the prompt on your host machine looks fancy, so I bet you have a problem with the PS1 on your OS X host.

To see if your host machine is causing the problem, drop into a subshell with a minimal PS1, then run Docker and see if the problem persists:

$ bash --rcfile <(echo "PS1='$ '") -i
$ docker exec -it ... bash
# ls

If the problem goes away, it is a problem with the PS1 on your host machine. Fix it permanently by following the directions in the link above so the length is calculated correctly.

mkasberg
  • 16,022
  • 3
  • 42
  • 46
  • Many thanks for your comment and I tried your code but still cannot show the message with a correct format. As I have installed the "oh-my-zsh" for the terminal. Is the related to the "oh-my-zsh" setting?Or anything setting I can change to test? – Kei Yip Jun 22 '17 at 06:30
  • Seems I reinstall the docker then back to normal. Thanks. – Kei Yip Jun 22 '17 at 09:51
  • 1
    What the OP is reporting is an issue with TTY initialization on some versions of Docker (now fixed upstream); nothing at all to do with the value of PS1. We have several preexisting questions about this on SO (flagged duplicate of each other) already. – Charles Duffy Jun 23 '17 at 02:59