First off, your example shows container / obstacle made of mesh without thickness. Obstacle object need to have volume to work. Don’t forget to add thickness.
About the Lattice, since lattice object is a parent of obstacle object, fluid simulation doesn’t see it. You know, lattice has no surface to react to.
Try to experiment with Shape key or Simple deform modifier.