I am attempting to start a LXC container and then run a command inside it. The problem is that even if the container is in RUNNING state, it has not completed all its boot. This produces trouble with /tmp (and, I guess, wit other initializations).
This can be illustrated with this call sequence that creates a container, starts it, waits for its RUNNING state and executes some commands; the commands create a file /tmp/hello, show a dir, wait a bit and show again the dir:
lxc-clone -B overlayfs -s -o vm -n c1 ; lxc-start -n c1 ; lxc-wait -n c1 -s RUNNING ; lxc-attach -n c1 -- su -c "touch /tmp/hello; ls -la /tmp; sleep 5; ls -la /tmp" slave ; lxc-stop -n c1 ; lxc-destroy -n c1
whose output is
Created container c1 as snapshot of vm
total 16
drwxrwxrwt 1 root root 4096 May 24 09:37 .
drwxr-xr-x 1 root nogroup 4096 May 24 09:37 ..
drwxrwxrwt 2 root root 4096 May 22 21:19 .ICE-unix
drwxrwxrwt 2 root root 4096 May 22 21:19 .X11-unix
-rw-rw-r-- 1 slave slave 0 May 24 09:37 hello
total 16
drwxrwxrwt 1 root root 4096 May 24 09:37 .
drwxr-xr-x 1 root nogroup 4096 May 24 09:37 ..
drwxrwxrwt 2 root root 4096 May 24 09:37 .ICE-unix
drwxrwxrwt 2 root root 4096 May 24 09:37 .X11-unix
and shows that the file /tmp/hello is deleted by some initialization script.
How to wait inside the container until the system is fully booted? Also, how to do it from outside the container?