francescou / docker-compose-ui

web interface for Docker Compose
http://francescou.github.io/docker-compose-ui
MIT License
1.54k stars 228 forks source link

Support for external web console #91

Closed kesonno closed 7 years ago

kesonno commented 7 years ago

Hi all!

I know that this topic was previously discussed several times ( #4 and #83 ).

This is my proposal for add the capability to start a shell inside the container. The basic idea is to decouple the console from the rest of UI, making it possible for the user to choose witch web console to use. This is based on our experience: so far we used docker-compose-ui together with our websocket-based console in a manual fashion, and want to integrate the two but without coupling them, mostly because the server part of our console is written in Go.

The only requirement for a web console is to support passing the container id (or name) and the command to exec as querystring parameters, for eg. with our web console you can call http://localhost:8888/?cid={containerName}&cmd={command}.

Then, you can pass the WEB_CONSOLE_PATTERN environment var to docker-compose-ui, that hold the pattern that will be used to build the url to load the console. Such pattern should include the {containerName} and {command} placeholders.

You can try the final result with this docker-compose.yml:

version: '3.0'
services:
    docker_compose_ui:
        restart: always
        image: bitbull/docker-compose-ui:latest
        environment:
            - WEB_CONSOLE_PATTERN=http://localhost:8888/?cid={containerName}&cmd={command}
        container_name: docker_compose_ui
        ports:
            - 5000:5000
        working_dir: /opt/docker-compose-projects/
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock

    docker-exec-web-console:
        restart: always
        image: bitbull/docker-exec-web-console
        container_name: docker_exec_web_console
        ports:
            - 8888:8888
        volumes:
            - /var/run/docker.sock:/var/run/docker.sock

Let me know what you think about this solution! I mention even @MichaelMackus because I've seen he's interested in the topic and he already started experimenting other solution.

Regards Gennaro

kesonno commented 7 years ago

Oh, I forgot to mention that in this PR there are even a couple of small global improvement:

francescou commented 7 years ago

Excellent job. I plan to apply some minor changes before the next release.

Thank you for your contribution!

MichaelMackus commented 7 years ago

Nice job @kesonno ! I like the ease of swapping out web console implementations, good idea.