How did the earth's atmosphere form?

The atmosphere is an envelope of different gases that surrounds the earth used by life as a reservoir of chemical compounds used in living systems. The atmosphere has no outer boundary just fades into space. The Atmosphere has about the same thickness as continental crust.