Thousands of prison officers walked out on Tuesday in protest at rising levels of violence in jails, prompting the government to seek a court injunction to force them back to work.