At night, it would have been customary for a shepherd to gather his sheep and pen them in some fashion to protect them. Sometimes a shepherd would gather them into a cave. Other times they would be gathered into an area surrounded by fencing made from branches. And to make sure he could control what came in and out of the area where the sheep were kept, there would only be one entrance. The shepherd would sleep at that entrance like a protective guard. Nothing could come in via that opening, or leave through it, without his blessing or permission.
As the Messiah who cares for His spiritual sheep, this analogy served as an accurate description of Christ's ministry and activity. In John 10:7, Jesus said, "I am the door of the sheep." To enter into the family of God, one must go through Him because He is the door. He's the one at the entrance.