<p>For example, a container runs the main thread and a goroutine. The main thread encounters an issue and terminates. Note that for Golang, termination of the main thread does not result in auto-termination of the goroutine.</p>
<ol>
<li><p>As the main thread has been terminated, will the container be killed and re-created? Or will the container continue running due to the goroutine is still running?</p>
</li>
<li><p>If the container will be killed and re-created after the main thread has been terminated, will this result in the goroutine getting terminated as well? Or will the goroutine continue running indefinitely and there is no easy way to terminate it now?</p>
</li>
</ol>

jtee
<p>If the main functions exists, the program is stopped. Nothing will run any more. It will release any used resource, like file descriptors and database connections.</p>
<p>In the below program, we will never see <em>done</em> being printed.</p>
<pre class="lang-golang prettyprint-override"><code>func main() {
    go func() {
        time.Sleep(time.Minute)
        fmt.Println(&quot;done&quot;)
    }()

    time.Sleep(time.Second * 3)
}
</code></pre>
<p><a href="https://play.golang.com/p/kPKZDdMcduS" rel="nofollow noreferrer">https://play.golang.com/p/kPKZDdMcduS</a></p>
<p>If the program with that main function was the foreground process of the container, then the container shuts down as its standard behaviour with containers.</p>
<p>If you run the below example, you can observe how the container shuts down as soon as the sleep finishes.</p>
<pre class="lang-sh prettyprint-override"><code>$ docker run --name sample busybox sleep 3 &amp;&amp; docker ps -a
CONTAINER ID   IMAGE     COMMAND     CREATED         STATUS                              PORTS     NAMES
fd4319261a0d   busybox   &quot;sleep 3&quot;   4 seconds ago   Exited (0) Less than a second ago             sample
</code></pre>
<p>If the container, the program is running in, is shut down, it's more or less as if you would pull the plug of your computer. Nothing will run on your computer any more. It's impossible.</p>
<p>I would encourage you to create some test scenarios yourself and validate this.</p>
