Hockey teams may dress no more than 18 players, excluding goalies, for each game. A list of all eligible players must be given to the referee or official scorer beforehand, and after that no roster changes can be made. Teams may use any number of goalies that they wish.
Generally, a club has two goalies ready to go each game, one of whom starts while the other sits on the bench. If both should get hurt, the rules allow a team to put any other player in goal, provided he is on the roster.
NHL franchises often have several players that regularly practice with the team but do not dress for games. They make up a sort of unofficial taxi squad and play only sporadically during the regular season and hardly at all in the playoffs.
General substitutions
Skaters can enter the game from the bench while play is in progress, provided that the people coming off the ice are within five feet of their bench and out of the play before the switch is made. That's known as changing on the fly. If a player doesn't get within five feet of the bench before his replacement hits the ice, his team is whistled for having too many players on the ice and loses a player to the penalty box for two minutes.
When play has stopped, the visiting team has the option of replacing its players on the ice. The referee allows a reasonable amount of time (5-10 seconds), and then he puts up his hands to indicate that the visitors cannot make any more changes. At that point, the home team may make its desired substitutions.
This setup gives the home team the advantage in determining matchups, letting it put out the players it wants to face those on the opposing squad. To counter this, the visiting team often substitutes as soon as play begins again and gets the people it wants onto the ice by quickly changing on the fly.
Goalie substitutions
As for goaltenders, they may be substituted at any time (usually during a stoppage in play — but not always). The new player coming in after a stoppage is allowed warm-ups only if his team's two goaltenders have already been knocked out of the game and he is goalie number 3. In that case, the netminder is allowed two minutes to get ready, unless he is being inserted for a penalty shot. Then he must go to work stone cold.