dbones
dbones

Reputation: 4504

"docker run -dti" with a dumb terminal

updated: added the missing docker attach.

Hi am trying to run a docker container, with -dti. but I cannot access with a terminal set to dumb. is there a way to change this (it is currently set to xterm, even though my ssh client is dumb)

example:

create the container

docker run -dti --name test -v /my-folder alpine /bin/ash
docker attach test
apk --update add nodejs
cd /my-folder
npm install -g gulp

the last command always contains ascii escape chars to move the cursor.

I have tried "export TERM=dumb" inside the running container, but it does not work.

is there a way to "run" this using the dumb terminal?

I am running this from a script on another computer, via (dumb) ssh.

Upvotes: 2

Views: 1876

Answers (3)

mud
mud

Reputation: 323

I was hitting this issue on OSx running docker, i had to do 2 things to stop the terminal/ascii/ansi escape sequences.

  1. remove the "t" option on the docker run command (from docker run -it ... to docker run -i...)
  2. ensure to force bash or sh shells used on osx when running the command from a script file, not the default zsh

Also

  • the escape sequences were not always visible on the terminal
  • even so, they still usually caused content corruption, even with SED brought to bear
  • they always were shown in my editor

Upvotes: 0

songcy
songcy

Reputation: 69

update: Yep -t is the problem. However if you want to see the entire process when running a command, maybe this way is better:

docker run -di --name test -v/my-folder alpine /bin/ash
docker exec -it test /bin/ash

finally you need to kill the container after all jobs finished.


docker run -d means "Run container in background and print container ID" not start the container as a daemon

Upvotes: 1

dbones
dbones

Reputation: 4504

using the -t which sets this https://docs.docker.com/engine/reference/run/#env-environment-variables, however removing effects the command prompt (the prompt is not shown)

possible solution 1 remove the -t and keep the -i. To see if the command has completed echo out a known token (ENDENDEND). ie

docker run -di --name test -v /my-folder alpine /bin/ash
docker attach test
apk --update add nodejs;echo ENDENDEND
cd /my-folder;echo ENDENDEND
npm install -g gulp;echo ENDENDEND

not pretty, but it works (there is no ascii in the results)

Possible solution 2 use the journal, docker can log out to the linux journal, this can be gathered as commands are executed in the container. (I have yet to fully test this one out. however the log seems to be a nicer output of what happened)

Upvotes: 2

Related Questions