Can I persist docker container? #7097
Replies: 4 comments 8 replies
-
You should look at mounting volumes to persist your workspace directories. See this template for example. https://github.com/matifali/coder-templates/blob/main/deeplearning/main.tf |
Beta Was this translation helpful? Give feedback.
-
I added BUT, if I don't stop the container after stopping the workspace, and start the workspace, wired things happen, unable to connect (the ui keeps loading, Probably, coder should stop all container when stopping a workspace? By the way, I see nothing related to stopping a container in terraform docs. Probably terraform simply doesn't support stopping a container? Can anyone tell me is that correct? |
Beta Was this translation helpful? Give feedback.
-
You cannot persist a container on workspace stop. Even if you somehow prevent terraform from destroying it it will be recreated/replaced on the next workspace restart. |
Beta Was this translation helpful? Give feedback.
-
I hit this same issue as well. Let me provide a little more usecase info to justify the need. We are using the Docker Container template w/a-few tweeks. We like that, it's fast! As opposed to DevContainer (EnvBuilder). We have a case where we use a mostly complete image, but we want to add some addtl things (like vscode extensions and a few other things). Here's the work-around that might-be-awful or might-not-be (we'll see I guess) add this to the bottom of your Container template
now, you must also change the count variable on your "workspace" resource
The full life cycle as tested is this...
I fear what happens if a stop doesn't actually stop? Maybe that's not a thing, but does seem like there is some potential for state inversion sync problem. We'll see I guess. |
Beta Was this translation helpful? Give feedback.
-
In my use case, we are not familiar with changing template each time, so I would like to keep the container there when stopping, and restart the container when starting, instead creating a new one.
I tried to add
lifecycle { ignore_changes = all }
to container, but the workspace cannot restart after a stop.Beta Was this translation helpful? Give feedback.
All reactions