Before I write a Compose entry for an unfamiliar image, I want to know which port it listens on, which user it runs as and which variables it already sets. All of that is in the image config.
docker image inspect --format '{{json .Config.ExposedPorts}}' nginx:alpine
docker image inspect --format '{{.Config.User}}' nginx:alpine
docker image inspect --format '{{json .Config.Env}}' nginx:alpine
For nginx:alpine that shows port 80/tcp, an empty user (so root), and variables like NGINX_VERSION. Other useful fields are .Config.Entrypoint, .Config.Cmd, .Config.WorkingDir, .Config.Volumes and .Config.StopSignal, which for nginx is SIGQUIT.
To see everything at once, pipe it through jq:
docker image inspect nginx:alpine | jq '.[0].Config'
The Volumes list is worth a look: each path there gets an anonymous volume when you run the image without mounting something on it.
ExposedPorts is documentation written by the image author, not a promise. An app can listen on a different port than it exposes, or on several. If a port does not answer, check inside the container what really listens. The image has to be pulled first; for a remote image, docker buildx imagetools inspect shows the manifest without downloading it.
Further reading: docker image inspect