Merge pull request #101 from pruizlezcano/docker-api

Added remote docker host
This commit is contained in:
pawelmalak 2021-10-09 01:36:51 +02:00 committed by GitHub
commit 65a33f16fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 56 additions and 8 deletions

View File

@ -177,6 +177,8 @@ labels:
# - flame.icon=custom to make changes in app. ie: custom icon upload # - flame.icon=custom to make changes in app. ie: custom icon upload
``` ```
And you must have activated the Docker sync option in the settings panel.
You can set up different apps in the same label adding `;` between each one. You can set up different apps in the same label adding `;` between each one.
```yml ```yml
@ -187,7 +189,28 @@ labels:
- flame.icon=icon-name1;icon-name2 - flame.icon=icon-name1;icon-name2
``` ```
And you must have activated the Docker sync option in the settings panel. If you want to use a remote docker host follow this instructions in the host:
- Open the file `/lib/systemd/system/docker.service`, search for `ExecStart` and edit the value
```text
ExecStart=/usr/bin/dockerd -H tcp://0.0.0.0:${PORT} -H unix:///var/run/docker.sock
```
>The above command will bind the docker engine server to the Unix socket as well as TCP port of your choice. “0.0.0.0” means docker-engine accepts connections from all IP addresses.
- Restart the daemon and Docker service
```shell
sudo systemctl daemon-reload
sudo service docker restart
```
- Test if it is working
```shell
curl http://${IP}:${PORT}/version
```
### Kubernetes integration ### Kubernetes integration

View File

@ -52,6 +52,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
bookmarksSameTab: 0, bookmarksSameTab: 0,
searchSameTab: 0, searchSameTab: 0,
dockerApps: 1, dockerApps: 1,
dockerHost: 'localhost',
kubernetesApps: 1, kubernetesApps: 1,
unpinStoppedApps: 1, unpinStoppedApps: 1,
}); });
@ -72,6 +73,7 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
bookmarksSameTab: searchConfig('bookmarksSameTab', 0), bookmarksSameTab: searchConfig('bookmarksSameTab', 0),
searchSameTab: searchConfig('searchSameTab', 0), searchSameTab: searchConfig('searchSameTab', 0),
dockerApps: searchConfig('dockerApps', 0), dockerApps: searchConfig('dockerApps', 0),
dockerHost: searchConfig('dockerHost', 'localhost'),
kubernetesApps: searchConfig('kubernetesApps', 0), kubernetesApps: searchConfig('kubernetesApps', 0),
unpinStoppedApps: searchConfig('unpinStoppedApps', 0), unpinStoppedApps: searchConfig('unpinStoppedApps', 0),
}); });
@ -275,6 +277,17 @@ const OtherSettings = (props: ComponentProps): JSX.Element => {
{/* DOCKER SETTINGS */} {/* DOCKER SETTINGS */}
<h2 className={classes.SettingsSection}>Docker</h2> <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> <InputGroup>
<label htmlFor="dockerApps">Use Docker API</label> <label htmlFor="dockerApps">Use Docker API</label>
<select <select

View File

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

View File

@ -65,16 +65,23 @@ exports.getApps = asyncWrapper(async (req, res, next) => {
if (useDockerApi && useDockerApi.value == 1) { if (useDockerApi && useDockerApi.value == 1) {
let containers = null; let containers = null;
const host = await Config.findOne({
where: { key: 'dockerHost' }
});
try { try {
let { data } = await axios.get( if(host.value.includes('localhost')) {
'http://localhost/containers/json?{"status":["running"]}', let { data } = await axios.get(`http://${host.value}/containers/json?{"status":["running"]}`,
{ {
socketPath: '/var/run/docker.sock', socketPath: '/var/run/docker.sock'
} });
);
containers = data; containers = data;
} else {
let { data } = await axios.get(`http://${host.value}/containers/json?{"status":["running"]}`);
containers = data;
}
} catch { } 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) { if (containers) {

View File

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