Joseph was living in the country of Egypt because the Ishmaelite people had taken him there and sold him to a man called Potiphar. Potiphar worked for the king and was in charge of the soldiers who looked after the king's palace.