Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in DevOps and Agile by (2.3k points)
edited by

So this is how I launched my container :

$ docker run -d myimage /bin/bash -c "mycommand"

With the above command, my container runs until "mycommand" is completely finished and then it stops, but it's not been deleted as using the "$ docker ps -a" I can still see the container.

How can I restart my container without changing the parameter and also keeping the data generated using "mycommand" ?

1 Answer

0 votes
by (6.9k points)
edited by

Use the below command to start a stopped container:

$ docker start container_name

To see the out put of your command add the -ai flag like given below:

$ docker start -ai container_name

You could also use the command $ docker restart [ container_name ] , but a disclaimer , this command is for running containers and not stopped ones.


Docker can be a little confusing without guidance, if you are looking to get trained in docker, make sure to check out docker training course.

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...