Self-creation of the same image

Hi, I have one docker-compose file. I build dockerfile in it. The dockerfile file is kept in the gitlab repo. After doing docker-compose, the Postgresql image gets up and the db_name, password, init.sql files come from the gitlab repo.However, it creates 2 Postgresql images. What is the cause and solution for this?

As you can see there are 2 postgresql images.