I've been using nsenter for the last few months to get a shell running on a container for debugging purposes. I have heard about and used docker exec which was introduced in version 1.3. Docker exec seems to be the new best practice for the purpose of getting inside a container for debugging purposes, but I'm wondering if there are any drawbacks to using docker exec versus nsenter. Information comparing the two is scant. Are there any specific problems I should watch out for or avoid when using docker exec versus nsenter?
Docker exec versus nsenter: Any gotchas?
6.1k Views Asked by L0j1k At
2
There are 2 best solutions below
3
On
Docker Exec vs. Nsenter
nsenterdoes not provide resource-limits as it does not usecgroupsunlikedockernsenteronly works on x86-64 archnsentercannot run inside a container (only on host)
There are differences between
nsenteranddocker exec; namely,nsenterdoesn't enter thecgroups, and therefore evades resource limitations. The potential benefit of this would be debugging and external audit. But for remote access, docker exec is the current recommended approach.
nsenteronly works on Intel 64 bits platforms.
nsenter still needs to run from the host; it cannot run inside a container.
ref: https://github.com/jpetazzo/nsenter/blob/master/README.md
That is not entirely clear right now. But I would support the view that since
docker execis the official way, to go with that. The author ofnsenteractually recommends usingdocker exec. If you encounter any drawbacks, he encourages you to report them though.