Does 'docker attach {CONTAINER_ID}' still work?

Questions/problems on Docker
Post Reply
Merc
Posts: 56
Joined: Tue Jun 09, 2015 2:29 am

Does 'docker attach {CONTAINER_ID}' still work?

Post by Merc » Sat Sep 23, 2017 7:27 pm

My apologies for a question that might properly be a Docker issue and not an OnlyOffice issue, but I thought it might be of general interest to administrators of OnlyOffice servers.

I am running the Community Edition of OnlyOffice and recently tried to attach to the running container of the Community Server using the (tried and true) command:

Code: Select all

sudo docker attach {CONTAINER_ID}
which resulted in a hung terminal. That is, nothing happened. Several attempts and restarts later with no progress I tried:

Code: Select all

sudo docker exec -it {CONTAINER_ID} bash
which worked fine. I got a # prompt and connected fine.

It's been a few years now and I have never had to resort to 'sudo docker exec' to connect to a container. Does anyone know if 'sudo docker attach' still works? Is one command preferred over the other?

I am running:

Docker version 17.05.0-ce, build 89658be
Ubuntu 16.04.3 LTS (GNU/Linux 4.4.0-96-generic x86_64)
onlyoffice/documentserver:4.4.3.7
onlyoffice/communityserver:9.1.0.418

Thanks very much for your feedback.

Maxim
Posts: 1859
Joined: Tue Oct 11, 2016 2:34 pm

Re: Does 'docker attach {CONTAINER_ID}' still work?

Post by Maxim » Mon Sep 25, 2017 9:34 am

Hello Merc!
You are right!
Have no idea why "docker attach" seems to hang and you have to use "docker exec" to execute commands in container, but it's not comfortable for me.
They say that it doesn't hang, but actually it is waiting for your input. I didn't check it.

Merc
Posts: 56
Joined: Tue Jun 09, 2015 2:29 am

Re: Does 'docker attach {CONTAINER_ID}' still work?

Post by Merc » Wed Sep 27, 2017 7:55 pm

In the past (actually up until this post) that condition where it does not actually hang was what I saw. I simply hit an additional carriage return and things worked as expected.

This time, no go. Nothing I did resulted in a command line prompt from the attached container. Ergo the exec command.

I'd be interested to know what you get if/when you try it.

-Thanks

Maxim
Posts: 1859
Joined: Tue Oct 11, 2016 2:34 pm

Re: Does 'docker attach {CONTAINER_ID}' still work?

Post by Maxim » Thu Sep 28, 2017 7:57 am

Hello Merc!
I use "docker exec" command every time when i need instead of "docker attach".

Post Reply