title: Can I get a docker container to restart itself from an image?
body: <p><strong>Background</strong></p>
  
  <p>I have a container, its running alot of stuff including a frontend that is exposed to other developers.</p>
  
  <p>Users are going to be uploading some of their shell/python scripts unto my container to be run.</p>
  
  <p>To keep the my container working, my plan is to send the script to a sibling container which will then run them and send me back the response. The user's scripts should be able to download external packages etc.</p>
  
  <p>Then I want the sibling container to be "cleaned"</p>
  
  <p><strong>Question</strong></p>
  
  <p>Can I have that sibling container restart itself from its source image once it is done running the user's script? This way users can get a consistently clean container to run their scripts on.</p>
  
  <p><strong>Note</strong></p>
  
  <p>If I am completely barking up the wrong tree with this solution, please let me know. I am trying to get some weird functionalities going and could be approaching this from the wrong angle.</p>
  
  <p><strong>EDIT 1 (other approaches and why I don't think I like them)</strong></p>
  
  <p>Two alternatives that I have thought of is having the container with the frontend run containers on it. Or have the sibling container run docker containers on it.  But these two solutions run into the difficulty of Docker-in-docker. The other solution may be to heighten my frontend container's permissions until it can make sibling containers on the fly for running scripts. But, I am worried that this may result in giving my frontend container unnecessarily high permissions.</p>
  
  <p><strong>EDIT 2 (all the documentation I have found on having a container restart itself)</strong></p>
  
  <p>I am aware of the documentation on <a href="https://docs.docker.com/docker-cloud/apps/autorestart/" rel="nofollow noreferrer">autorestart</a>, but I don't believe that this will clean the containers contents. For instance if a file was downloaded onto it.</p>