Running images prepared using docker-compose

I have a following question related to running images prepated by docker-compose.

Assuming that the compose file shares some ports (and does propper mapping) then while running the image with docker, do I need to list (again) same ports as in the compose file using the “-p” parameter?

When you run a Docker image, either via regular CLI or compose, you always need to explicitly state the ports to be opened.

A Dockerfile can include expose with ports, but that is just a hint, they are not automatically opened for listening.

Your question is not perfectly clear to me, Maybe you should show what commands you mean. Compose is a plugin of docker after all, so I guess you meant running a docker compose command, but the only way to redefine ports is using docker compose run and not docker compose up.

docker compose run allows you to define ports exactly because that ignores the port definition since you can run the same service multiple times.

https://docs.docker.com/reference/cli/docker/compose/run/

The second difference is that the docker compose run command does not create any of the ports specified in the service configuration. This prevents port collisions with already-open ports.

(more details in the linked documentation)