An image forming apparatus comprising: a toner container configured to be attached to an attachment position set in an apparatus main body; a support member configured to support the toner container so that the toner container can be moved between the attachment position and a detachment position that is separated from the attachment position toward a predetermined first surface of the apparatus main body; a lock member provided on the support member in such a way as to be movable in a first direction that extends along the first surface, the lock member configured to be displaced between a lock position and a removal position, wherein when the lock member is located at the lock position, the lock member is engaged with the toner container so that the toner container is locked to the attachment position, and when the lock member is located at the removal position, a lock of the toner container is removed; a lock removing portion configured to, when a predetermined removal condition is satisfied, move the lock member from the lock position to the removal position to remove the lock of the toner container; an elastic member configured to bias the lock member toward the lock position; and a moving mechanism configured to move the toner container toward the detachment position when the lock removing portion removes the lock, characterized in that the moving mechanism includes: a first pressing portion configured to, when the lock removing portion has moved the lock member from the lock position toward the removal position, press the toner container from the attachment position toward the detachment position, a second pressing portion configured to press the toner container that has been pressed to a middle position that is set between the attachment position and the detachment position, by the first pressing portion, from the middle position toward the detachment position, the lock removing portion moves the lock member toward the removal position against a biasing force of the elastic member, and when the lock member has moved from the lock position to the removal position, the first pressing portion presses the toner container from the attachment position to the middle position. a toner container configured to be attached to an attachment position set in an apparatus main body; a support member configured to support the toner container so that the toner container can be moved between the attachment position and a detachment position that is separated from the attachment position toward a predetermined first surface of the apparatus main body; a lock member provided on the support member in such a way as to be movable in a first direction that extends along the first surface, the lock member configured to be displaced between a lock position and a removal position, wherein when the lock member is located at the lock position, the lock member is engaged with the toner container so that the toner container is locked to the attachment position, and when the lock member is located at the removal position, a lock of the toner container is removed; a lock removing portion configured to, when a predetermined removal condition is satisfied, move the lock member from the lock position to the removal position to remove the lock of the toner container; an elastic member configured to bias the lock member toward the lock position; and a moving mechanism configured to move the toner container toward the detachment position when the lock removing portion removes the lock, characterized in that the moving mechanism includes: a first pressing portion configured to, when the lock removing portion has moved the lock member from the lock position toward the removal position, press the toner container from the attachment position toward the detachment position, a second pressing portion configured to press the toner container that has been pressed to a middle position that is set between the attachment position and the detachment position, by the first pressing portion, from the middle position toward the detachment position, the lock removing portion moves the lock member toward the removal position against a biasing force of the elastic member, and when the lock member has moved from the lock position to the removal position, the first pressing portion presses the toner container from the attachment position to the middle position.