<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">This is a best-practice question.<div class=""><br class=""></div><div class="">I’d like to automate testing of a web application (running in a container) by running curl from the host. The logical sequence should be:</div><div class=""><br class=""></div><div class="">* boot container using local tar file or existing directory</div><div class="">* wait until container is-system-running=true</div><div class="">* on the container, execute a few commands</div><div class="">* on the host, run curl against the container</div><div class="">* tear down the container</div><div class=""><br class=""></div><div class="">I need to boot the container, and the image I need to use for this test brings up a login prompt at the console.</div><div class=""><br class=""></div><div class="">I’m thinking of doing something like:</div><div class="">> machinectl import-tar foo.tar foo</div><div class="">> machinectl start foo</div><div class="">> ssh foo systemctl is-system-running</div><div class="">until satisfied</div><div class="">> ssh foo some other commands</div><div class="">> curl <a href="http://foo/" class="">http://foo/</a>…</div><div class="">> machinectl poweroff foo</div><div class=""><div class="">> machinectl status foo</div></div><div class="">until off</div><div class=""><br class=""></div><div class="">But I don’t like the “container import and registration” part of this, because my container is very ephemeral and might only live for a few minutes if the test passes.</div><div class=""><br class=""></div><div class="">Alternatively I could create myself a “test@.service” which would be identical to systemd-nspawn@.service, except it would use the directory as the %I instead of the machine name, so I could start it like:</div><div class="">> systemctl start test@/my/container/directory</div><div class=""><br class=""></div><div class="">Or I could fork off the systemctl-nspawn command in my test script.</div><div class=""><br class=""></div><div class="">Opinions? I figure this is a common-enough scenario that there might be some opinions on this list ...</div><div class=""><br class=""></div><div class="">Cheers,</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Johannes.</div><div class=""><br class=""></div></body></html>