daemon/attach: avoid mem alloc for interface

This makes the same changes as #8109 for daemon/attach.go.