Added remote docker host

This commit is contained in:
Pablo Ruiz 2021-10-06 22:17:43 +02:00
parent afc0f16470
commit 231dbc4577
4 changed files with 32 additions and 7 deletions

View File

@ -52,6 +52,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
bookmarksSameTab: 0,
searchSameTab: 0,
dockerApps: 1,
dockerHost: 'localhost',
kubernetesApps: 1,
unpinStoppedApps: 1,
});
@ -72,6 +73,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
bookmarksSameTab: searchConfig('bookmarksSameTab', 0),
searchSameTab: searchConfig('searchSameTab', 0),
dockerApps: searchConfig('dockerApps', 0),
dockerHost: searchConfig('dockerHost', 'localhost'),
kubernetesApps: searchConfig('kubernetesApps', 0),
unpinStoppedApps: searchConfig('unpinStoppedApps', 0),
});
@ -275,6 +277,17 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
{/* DOCKER SETTINGS */}
<h2 className={classes.SettingsSection}>Docker</h2>
<InputGroup>
<label htmlFor="dockerHost">Docker Host</label>
<input
type="text"
id="dockerHost"
name="dockerHost"
placeholder="dockerHost:port"
value={formData.dockerHost}
onChange={(e) => inputChangeHandler(e)}
/>
</InputGroup>
<InputGroup>
<label htmlFor="dockerApps">Use Docker API</label>
<select

View File

@ -19,6 +19,7 @@ export interface SettingsForm {
bookmarksSameTab: number;
searchSameTab: number;
dockerApps: number;
dockerHost: string;
kubernetesApps: number;
unpinStoppedApps: number;
}

View File

@ -65,16 +65,23 @@ exports.getApps = asyncWrapper(async (req, res, next) => {
if (useDockerApi && useDockerApi.value == 1) {
let containers = null;
const host = await Config.findOne({
where: { key: 'dockerHost' }
});
try {
let { data } = await axios.get(
'http://localhost/containers/json?{"status":["running"]}',
if(host.value.includes('localhost')) {
let { data } = await axios.get(`http://${host.value}/containers/json?{"status":["running"]}`,
{
socketPath: '/var/run/docker.sock',
}
);
containers = data;
socketPath: '/var/run/docker.sock'
});
containers = data;
} else {
let { data } = await axios.get(`http://${host.value}/containers/json?{"status":["running"]}`);
containers = data;
}
} catch {
logger.log("Can't connect to the docker socket", 'ERROR');
logger.log(`Can't connect to the docker api on ${host.value}`, 'ERROR');
}
if (containers) {

View File

@ -68,6 +68,10 @@
"key": "dockerApps",
"value": false
},
{
"key": "dockerHost",
"value": "localhost"
},
{
"key": "kubernetesApps",
"value": false