Containers are mostly namespaces: a process gets its own view of the network, mounts, process IDs and so on. lsns lets you see them from the host.
sudo lsns -t net
-t picks the type: mnt, net, ipc, user, pid, uts, cgroup or time, and you can give it more than once. With -t net, each Docker container on its own network shows up as a separate network namespace with the process that holds it.
To see which namespaces one process lives in:
sudo lsns -p 1234
Comparing that with lsns -p 1 shows at a glance which namespaces a container shares with the host and which are its own.
For scripts, the man page recommends setting the columns yourself with --output, since the default output can change between versions. -H lists the columns you can pick.
Caveats. Without root the list is incomplete, so use sudo. A namespace that has no process left in it does not show up. And with -t net some cells span several lines; -W keeps each entry on one line.
Further reading: lsns manual