<p>If you don't name a container when you run it Docker will make up a random name for you.  This is handy for differentiating different invocations of a container without resorting to hex values.  You can see by <a href="https://github.com/moby/moby/blob/master/pkg/namesgenerator/names-generator.go" rel="nofollow noreferrer">checking the source</a> all of the possible names that could be generated.</p>

CC BY-SA 4.0
2022-01-26T15:05:05.827Z
Thanks chicks. I notice when I do a 'docker run busybox echo "hello from busybox"' several times and then do a "docker ps -a" I see I get several different names in the NAMES column. If one of the names is "focused_clarke", should I then be able to do 'docker run focused_clarke echo "hello from focused_clarke" instead? When I do I get repository does not exist.
user2220115
CC BY-SA 4.0
2022-01-26T16:12:18.753Z
The names don't make sense in the run context, but should work for when you're looking at logs or trying to stop one of several otherwise identical containers.
chicks
CC BY-SA 4.0
2022-01-25T20:40:48.600Z
2022-01-25T20:40:48.600Z
chicks
<p>Run is used for running a new container.</p>
<p>Exec is used for doing something inside of an existing container.</p>
<pre><code>docker exec -it &lt;container_id_or_name&gt; echo &quot;I'm inside the container!&quot;
</code></pre>
<p>So, when you use <code>exec</code>, you can use the container name from your running container, as shown in our output.</p>

CC BY-SA 4.0
2022-01-21T17:10:22.977Z
Looks like neither command is working for me. "run -it sweet_curran bash" gives me "Unable to find image 'sweet_curran:latest' locally" and "docker exec -it sweet_curran bash" gives me "Container d69c6f... is not running".
user2220115
CC BY-SA 4.0
2022-01-21T18:35:30.020Z
Yeah... read your output in your question.   "Exited (0) 10 minutes ago" - your container stopped / isn't actually running - but the exec command did its job and found the container you meant from the name.  If you want it to stay up, you need to run a process that won't stop (e.g. a web service), or you need to tell it to sleep or something.  Also, generally run things as a daemon with "-d" so that they don't rely on your command line/are non-blocking.  Otherwise when you break out of the CLI they will die.
John Humphreys
CC BY-SA 4.0
2022-01-21T18:38:49.400Z
Read this -> https://docker-curriculum.com/.  May catch you up on some fundamentals.
John Humphreys
CC BY-SA 4.0
2022-01-21T21:49:04.247Z
Whether it is with docker exec or docker run, if it is stopped how can I run it again using the name in the "Names" field "sweet_curran"? Thanks.
user2220115
CC BY-SA 4.0
2022-01-21T22:00:40.037Z
I think you need to read docker fundamentals.  A container lives for the scope of the process that it executes.   Since your process is just bash, it stopped.  If it was a database like mysql, it would be around forever to jump into.
John Humphreys
CC BY-SA 4.0
2022-01-21T16:48:02.387Z
2022-01-21T16:48:02.387Z
John Humphreys
<p>When I run the &quot;docker ps -a&quot; command following command I fields:</p>
<pre><code>CONTAINER ID        IMAGE                 COMMAND             CREATED             STATUS                      PORTS               NAMES
d69c6f81b591        paigeeworld/centos7   &quot;/bin/bash&quot;         10 minutes ago      Exited (0) 10 minutes ago                       sweet_curran
</code></pre>
<p>If I try to do a &quot;docker run -it sweet_curran bash&quot; I get an &quot;unable to find image&quot; error. What the &quot;Names&quot; field used for if I cannot use it to run the image?</p>

<docker>
Names field in docker ps -a command
user2220115
# Names field in docker ps -a command

(Asked by: username_0 on 2022-01-21)

When I run the "docker ps -a" command following command I fields:
CONTAINER ID        IMAGE                 COMMAND             CREATED             STATUS                      PORTS               NAMES
d69c6f81b591        paigeeworld/centos7   "/bin/bash"         10 minutes ago      Exited (0) 10 minutes ago                       sweet_curran

If I try to do a "docker run -it sweet_curran bash" I get an "unable to find image" error. What the "Names" field used for if I cannot use it to run the image?

**Tags:** docker


---

## 2 answers

### Answer by username_1 on 2022-01-25. Score: 1

If you don't name a container when you run it Docker will make up a random name for you. This is handy for differentiating different invocations of a container without resorting to hex values. You can see by [checking the source](https://github.com/moby/moby/blob/master/pkg/namesgenerator/names-generator.go) all of the possible names that could be generated.

> **Comments:**
> **username_0**: Thanks username_1. I notice when I do a 'docker run busybox echo "hello from busybox"' several times and then do a "docker ps -a" I see I get several different names in the NAMES column. If one of the names is "focused_clarke", should I then be able to do 'docker run focused_clarke echo "hello from focused_clarke" instead? When I do I get repository does not exist.  
> **username_1**: The names don't make sense in the run context, but should work for when you're looking at logs or trying to stop one of several otherwise identical containers.  

---

### Answer by username_2 on 2022-01-21. Score: 0

Run is used for running a new container.
Exec is used for doing something inside of an existing container.
docker exec -it  echo "I'm inside the container!"

So, when you use exec, you can use the container name from your running container, as shown in our output.

> **Comments:**
> **username_0**: Looks like neither command is working for me. "run -it sweet_curran bash" gives me "Unable to find image 'sweet_curran:latest' locally" and "docker exec -it sweet_curran bash" gives me "Container d69c6f... is not running".  
> **username_2**: Yeah... read your output in your question.   "Exited (0) 10 minutes ago" - your container stopped / isn't actually running - but the exec command did its job and found the container you meant from the name.  If you want it to stay up, you need to run a process that won't stop (e.g. a web service), or you need to tell it to sleep or something.  Also, generally run things as a daemon with "-d" so that they don't rely on your command line/are non-blocking.  Otherwise when you break out of the CLI they will die.  
> **username_2**: Read this -> https://docker-curriculum.com/.  May catch you up on some fundamentals.  
> **username_0**: Whether it is with docker exec or docker run, if it is stopped how can I run it again using the name in the "Names" field "sweet_curran"? Thanks.  
> **username_2**: I think you need to read docker fundamentals.  A container lives for the scope of the process that it executes.   Since your process is just bash, it stopped.  If it was a database like mysql, it would be around forever to jump into.  

---

