When I do it on my macOS using Docker Desktop I get the same result, but Docker Desktop uses cgroup v2 in the virtual machine and I have cgroup v1 on my Linux where I can see more.
I don’t know what is the best way to check that if you are in a container, since it could be other contaier not created by Docker, but in case of Docker, you could for example check the mountinfo
cat /proc/1/mountinfo
Or the mount command would be easier to use in a script:
mount | grep 'overlay on /'
If it returns something, it is probably a container:
overlay on / type overlay (rw,relatime,lowerdir=/var/lib/docker/overlay2/l/2VXBE3ETYFJ6U26GXDORMTSYEE:/var/lib/docker/overlay2/l/35BQNRRKIP7OZQDT7KLUCAQOJD,upperdir=/var/lib/docker/overlay2/3a009df8e82ff8d25b10527111283ea3bd90471ccf5fab00626e53bd468d4ae1/diff,workdir=/var/lib/docker/overlay2/3a009df8e82ff8d25b10527111283ea3bd90471ccf5fab00626e53bd468d4ae1/work)
On the other hand, systemd uses an environment variable to work differently in a container.