Skip to content

Instantly share code, notes, and snippets.

@jmacqueen
Created May 11, 2021 14:10
Show Gist options
  • Save jmacqueen/aca9e0fe682f128138899d4d79a104e8 to your computer and use it in GitHub Desktop.
Save jmacqueen/aca9e0fe682f128138899d4d79a104e8 to your computer and use it in GitHub Desktop.
export const command = `/usr/local/bin/docker ps --format '{{.Names}}\t{{.Ports}}'`
export const refreshFrequency = 5000 // ms
export const render = ({ output }) => {
if (!output) return <h3>Docker daemon not responding</h3>
const lines = output.split("\n")
function tableRow(line) {
const splitLine = line.split(/\t/)
return (
<tr>
<td>{splitLine[0]}</td>
<td>{splitLine[1]}</td>
</tr>
)
}
return (
<table>
<thead>
<tr>
<th>Name</th>
<th>Ports</th>
</tr>
</thead>
<tbody>
{lines.filter(l => l).sort().map(tableRow)}
</tbody>
</table>
)
}
export const className = `
background-color: rgba(0, 0, 0, 0.5);
padding: 0.5rem;
color: #fff;
font-family: monospace ;
th {
font-size: 1rem;
}
td {
border-bottom: 1px solid rgba(0,0,0,0.5);
padding: 0.25rem 0.5rem;
}
`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment