# Run command in stopped container

**URL:** <https://forums.docker.com/t/run-command-in-stopped-container/343>\
**Category:** General\
**Created:** [November 5, 2014, 2:33pm UTC](https://forums.docker.com/t/run-command-in-stopped-container/343 "2014-11-05T14:33:53Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![programmerq](https://sea3.discourse-cdn.com/docker/user_avatar/forums.docker.com/programmerq/32/208_2.png) [@programmerq](https://forums.docker.com/u/programmerq)\
**Post date:** [November 11, 2014, 4:45pm UTC](https://forums.docker.com/t/run-command-in-stopped-container/343/11 "2014-11-11T16:45:07Z")

</div>

Containers are indeed process-centric. Once that process exits, the container is done. having the ability to commit is docker’s way of taking the resulting state from that process and preserving it.

This is a key difference between containers and say, a virtual machine.

Would you be willing to share a more specific use case that you are after? All the `echo`, `tail`, and `sleep` commands were just examples that may not illustrate a proper use case very clearly.

Data volumes in docker may be helpful for whatever your use case might be, for example.

Say I fire up a process in a container which will have some resulting data stored on that volume. Now, I want to fire up another container and use that data, I just have to attach the same volume. Here’s another made-up example:

```
$ docker run -v /host/path/to/volume:/vol ubuntu /bin/bash -c 'date | tee /vol/result.txt'
Tue Nov 11 07:07:11 UTC 2014
$ docker run -v /host/path/to/volume:/vol ubuntu /bin/bash -c 'cat /vol/result.txt'
Tue Nov 11 07:07:11 UTC 2014

```

More information on volumes here: [https://docs.docker.com/userguide/dockervolumes/](https://docs.docker.com/userguide/dockervolumes/)

---

_[View the full topic](https://forums.docker.com/t/run-command-in-stopped-container/343)._
