Genesis 40:1-4

The Cupbearer and the Baker

40:1 After these things happened, the cupbearer to the king of Egypt and the royal baker offended their master, the king of Egypt. 40:2 Pharaoh was enraged with his two officials, the cupbearer and the baker, 40:3 so he imprisoned them in the house of the captain of the guard in the same facility where Joseph was confined. 40:4 The captain of the guard appointed Joseph to be their attendant, and he served them.

They spent some time in custody.