Some time after this, the 1cupbearer of the king of Egypt and his baker committed an offense against their lord the king of Egypt.
References for Genesis 40:1
And Pharaoh was angry with his two officers, the chief cupbearer and the chief baker,
2and he put them in custody in the house of the captain of the guard, in the prison where Joseph was confined.
References for Genesis 40:3
The captain of the guard appointed Joseph to be with them, and he attended them. They continued for some time in custody.
And one night they both dreamed--the cupbearer and the baker of the king of Egypt, who were confined in the prison--each his own dream, and each dream with its own interpretation.
When Joseph came to them in the morning, he saw that they were troubled.
So he asked Pharaoh's officers who were with him in custody in his master's house, 3"Why are your faces downcast today?"
References for Genesis 40:7