At the Pike County Correctional Facility, a contraband economy has sprung up around limited supplies of soap.

Fights have broken out between prisoners in Montgomery County over phone time since the state prisons banned visitors.

Inmate trustees in Schuylkill County have logged 12-hour shifts fulfilling thousands of commissary orders from peers stockpiling what they could before their detention center went into lockdown.

And at least 180 immigration detainees in the York County Prison launched a hunger strike over the weekend.

Though public health advocates, defense lawyers, and even some prosecutors have been raising alarm for weeks about the risk of a coronavirus outbreak among Pennsylvania’s incarcerated population, it is only in the last several days that a snapshot has begun to emerge of what life is like for the tens of thousands of people living and working in the state’s prisons, county jails, and immigration lockups amid the pandemic.

Court filings, interviews, and social media postings detail an increasingly tense environment — one in which close quarters makes social distancing all but impossible, and where daily contact between on-edge inmates and concerned guards has led to a growing sense that widespread exposure is inevitable.

“I cannot sleep. I cannot breathe, and I feel like I’m going to die,” wrote Mayowa Abayomi Oyediran, an asthmatic Nigerian asylum seeker housed in the York County Prison, in a sworn affidavit last week. “Nobody in here can even get me an inhaler. How can they save us from this virus?”

Until a federal judge in Harrisburg ordered his release Tuesday, Oyediran, 40, had been housed in a cell block packed with as many as 60 other inmates — using the same rarely cleaned six toilets and showers, eating shoulder to shoulder, and sleeping at night in bunks so close together he could reach out and touch his cellmate on the other side.

Inmates in other facilities have described similar conditions, and worry about guards showing up to work with suspicious coughs and fellow prisoners who have recently developed fevers.

At SCI Phoenix in Collegeville, some inmates have resorted to makeshift masks “almost the size of a diaper” for protection, said Thomas Schilk, who is serving a life sentence for second-degree murder.

Meanwhile, Matthew Stiegler, an attorney who represents a 69-year-old inmate seeking release from the federal detention center at Joint Base McGuire-Dix-Lakehurst, said inmates there were recently called to a town hall meeting with more than 100 people in a communal hall. The guards told them they were planning to put more hand soap in the restrooms — sometime in the future.

“It’s a scene out of a Hollywood disaster movie,” he said.

In many ways, advocates say, the characteristics that have long defined life in custody — shared cells, communal bathrooms, a lack of freedom of movement — are the very conditions that make such facilities vulnerable to a fast-moving and easily communicable virus.

“It is impossible for me to stay six feet away from other people,” wrote Christopher Aubry, who is serving a one- to 23-month sentence for simple assault in the Montgomery County prisonl, in a court affidavit Monday.

But corrections officials at the state, local, and federal level have resisted calls for widespread releases of low-level offenders or those most at risk for infection, and said such moves could pose a public safety risk. They contend that prison staff are fully equipped to manage inmates’ health and are taking all possible precautions to prevent an outbreak within their walls.

The Philadelphia Department of Prisons has begun quarantining newly admitted jail inmates for 14 days, and anyone entering its facilities is screened for temperature and possible coronavirus symptoms. In federal prisons, new arrivals are monitored for coughs or fevers, and officials have temporarily banned personal and most legal visits.

The Pennsylvania Department of Corrections, meanwhile, which oversees about 45,000 inmates in the state, placed its entire system under quarantine late Sunday after a prisoner tested positive at SCI Phoenix.

“I don't want to wait until we have several cases in our system to act,” Corrections Secretary John Wetzel said in a statement. “We're taking this proactive measure now."

That may not be enough.

On Monday, the ACLU of Pennsylvania petitioned the state Supreme Court, pushing for immediate release of five inmates with underlying medical conditions that would make them most at risk. Lawyers argued that it is only a matter of time before a crisis erupts like the one unfolding at New York City’s Rikers Island, where at least 300 inmates and staff have tested positive. The facility’s chief doctor described the situation as “a public health disaster unfolding before our eyes.”

Three Pennsylvania state prison system guards had tested positive for the virus as of Tuesday. And officials in Philadelphia reported Friday that at least one prisoner and one guard have been infected in the city’s jails, while at least five others have been quarantined. They declined to provide an updated tally Tuesday. Montgomery and Delaware Counties have identified cases among staff and inmates as well.

Meanwhile, the union representing the state’s corrections officers continues to raise concern about continued nonessential transfers from county jails to prisons, which can expose even the most tightly regulated facilities to possible exposure from new arrivals, said union president Larry Blackwell.

The problems plaguing prisons and jails are only exacerbated in immigration detention centers, where some inmates don’t speak English fluently, frustrating efforts to educate prisoners on steps they can take to protect themselves.

Meijing Lin, 45, sought asylum in the United States after being forcibly sterilized by the Chinese government, and was housed in a pod at the York County prison with 50 to 60 other inmates while awaiting a hearing.

She sensed the anxiety levels rising all month among her fellow inmates and guards. But as a Mandarin speaker, she said, she understood very little of it.

“If they are giving advice on how to prevent the spread of COVID-19, I don’t know what it is,” she said in a translated federal court affidavit seeking her release last week.

Courtney Stubbs, a 52-year-old Jamaican man under a deportation order in the Pike County Correctional Facility after a drug-related conviction, said his panic kicked in when one day the television in the detention center’s rec room suddenly switched from its usual CNN to Netflix.

“We used to ask the COs to put on Netflix to watch movies all the time, and they wouldn’t do it,” he wrote. “Now it’s the only thing they put on. I feel like they did this so we wouldn’t get information about the coronavirus” in the outside world.

On Tuesday, a federal judge in Harrisburg described Stubbs’ report of guards limiting information as “troubling,” and ruled that there were no precautions that federal immigration authorities could reasonably take to protect inmates like him with high-risk medical conditions.

He ordered the immediate release of Stubbs, Lin, and eight other medically vulnerable immigrant detainees, saying it would be “unconscionable” and “barbaric” not to do so.

But at least one of them, in court filings, worried it might be too late. A hacking cough from his cellmate in a bed three feet away kept Bharatkumar G. Thakker, 61, of India, awake for nights before the judge’s order led to his release from the Pike County Correctional Facility on Tuesday.

Last week, Thakker started coughing himself.

Staff writer Samantha Melamed contributed to this article.