You can use the container names to address containers. Whether this is a randomly generated name (docker run… with no --name flag), the compose working dir and service name, or the compose container_name var.
I also rarely use the container command. docker is sufficient, or docker compose … while in the working dir of a given compose stack.