Reputation: 1990
basically, I have a running container I would like to attach console on it.
I have used docker run -p 8080:80 test
to start my container. It seems to be working fine.
my docker ps looks like this :
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
81b27e2525f1 test "/bin/sh -c /start.sh" 13 minutes ago Up 13 minutes 8080/tcp, 0.0.0.0:8080->80/tcp vigilant_bassi
Then tried to attach my a console
user@user:~$ docker attach 81b27e2525f1
ls
^C
ls
^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[B^[[B^[[B^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^[[A^C^C^C^C^[[A^[[A^[[A^[[A^[[A
This is not working and I am unable to detach.
Then I thought it was a bug I tried to open on new and I had the exact same issue. Now I have multiple consoles blocked.
I found this question, it is not the same problem.
What am I doing wrong?
ps my docker version is : Docker version 1.13.1, build 092cba3
Upvotes: 5
Views: 4869
Reputation: 36823
You can see the output of your container without attaching to it:
docker logs -f <container-id>
But if you really need to attach to it you have to start it with the -it flags:
docker run --detach -it -p 8080:80 test
To attach:
docker attach <container-id>
Don't use Ctrl+C to detach because that will be a signal that will quit program. Use Ctrl+P then Ctrl+Q to detach.
Upvotes: 1
Reputation: 1327384
Try instead a docker exec
, for debugging purpose:
docker exec -it test bash
(assuming your test image has a bash
installed, or at least an sh
. If based on Alpine, an ash
)
docker attach
uses the container’s stdio/stderr, so you need to makle sure your script is actually flushing/printing something.
Upvotes: 5