# Docker attach gives empty new line

**URL:** https://meta.discourse.org/t/docker-attach-gives-empty-new-line/254910
**Category:** Self-hosting
**Tags:** docker-manager
**Created:** [February 12, 2023, 4:16pm UTC](https://meta.discourse.org/t/docker-attach-gives-empty-new-line/254910 "2023-02-12T16:16:40Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![bquast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bquast/32/289307_2.png) [@bquast](https://meta.discourse.org/u/bquast)
#### Post date: [February 12, 2023, 4:16pm UTC](https://meta.discourse.org/t/docker-attach-gives-empty-new-line/254910/1 "2023-02-12T16:16:40Z")

</div>

Hello, I have an instance of docker (the supported image).

When I try to `docker attach` it just shows the cursor blinking on an empty line, there is no response to commands like `ls`.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [February 12, 2023, 8:31pm UTC](https://meta.discourse.org/t/docker-attach-gives-empty-new-line/254910/2 "2023-02-12T20:31:22Z")

</div>

How about

```
docker exec -it app bash -c "your command here"

```

---

<div class="post-metadata">

### Author: ![bquast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bquast/32/289307_2.png) [@bquast](https://meta.discourse.org/u/bquast)
#### Post date: [February 12, 2023, 8:32pm UTC](https://meta.discourse.org/t/docker-attach-gives-empty-new-line/254910/3 "2023-02-12T20:32:39Z")

</div>

Yes that worked (with `ls`)

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [February 12, 2023, 8:33pm UTC](https://meta.discourse.org/t/docker-attach-gives-empty-new-line/254910/4 "2023-02-12T20:33:43Z")

</div>

Great! Please mark as solved so the topic gets closed. Glad that worked!

---

<div class="post-metadata">

### Author: ![bquast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bquast/32/289307_2.png) [@bquast](https://meta.discourse.org/u/bquast)
#### Post date: [February 12, 2023, 8:34pm UTC](https://meta.discourse.org/t/docker-attach-gives-empty-new-line/254910/5 "2023-02-12T20:34:19Z")

</div>

Done!

But I’d still like to know what the problem was

and

How can I functionally attach?

---

<div class="post-metadata">

### Author: ![Ed\_S](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/ed_s/32/134015_2.png) [@Ed\_S](https://meta.discourse.org/u/Ed_S)
#### Post date: [February 12, 2023, 8:57pm UTC](https://meta.discourse.org/t/docker-attach-gives-empty-new-line/254910/6 "2023-02-12T20:57:39Z")

</div>

Is it something like `./launcher enter app` that you’re looking for? That’ll give you a shell prompt inside the container. I don’t know how to do it with docker directly, but maybe `docker exec -it app bash`

---

<div class="post-metadata">

### Author: ![bquast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bquast/32/289307_2.png) [@bquast](https://meta.discourse.org/u/bquast)
#### Post date: [February 12, 2023, 9:01pm UTC](https://meta.discourse.org/t/docker-attach-gives-empty-new-line/254910/7 "2023-02-12T21:01:27Z")

</div>

> [@Ed\_S](#):
>
> That’ll give you a shell prompt inside the container

Indeed that is my objective, I want to sniff around the database tables.

I will try `docker exec -it app bash`

I thought that this was what `docker attach` was for, but I’m not an expert.

---

<div class="post-metadata">

### Author: ![bquast](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/bquast/32/289307_2.png) [@bquast](https://meta.discourse.org/u/bquast)
#### Post date: [February 12, 2023, 9:07pm UTC](https://meta.discourse.org/t/docker-attach-gives-empty-new-line/254910/8 "2023-02-12T21:07:42Z")

</div>

Looking further based on the hints fomr @pfaffman and @Ed_S, this answer from SO explained it well (accepted answer)

> <https://stackoverflow.com/questions/30172605/how-do-i-get-a-console-like-connection-into-a-docker-containers-shell>

**EDIT** : the point is that a web server is running on the image, so `docker attach` doesn’t work, but the `exec` command does

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [February 13, 2023, 3:06pm UTC](https://meta.discourse.org/t/docker-attach-gives-empty-new-line/254910/9 "2023-02-13T15:06:11Z")

</div>

> [@bquast](#):
>
> Indeed that is my objective, I want to sniff around the database tables.

Then maybe use the [data explorer](https://meta.discourse.org/t/32566?silent=true) plugin. That’s a much better way to explore the database.

But maybe you’d be interested in [Administrative Bulk Operations](https://meta.discourse.org/t/administrative-bulk-operations/118349)

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [March 15, 2023, 3:06pm UTC](https://meta.discourse.org/t/docker-attach-gives-empty-new-line/254910/10 "2023-03-15T15:06:48Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
