mirror of https://github.com/portainer/portainer
Allow a user to bind to a unix socket
parent
efd58156f7
commit
75d5bd1217
17
Dockerfile
17
Dockerfile
|
@ -1,25 +1,16 @@
|
||||||
# Dockerfile for DockerUI
|
|
||||||
|
|
||||||
FROM ubuntu:12.04
|
FROM ubuntu:12.04
|
||||||
|
|
||||||
MAINTAINER Michael Crosby http://crosbymichael.com
|
|
||||||
|
|
||||||
RUN apt-get update
|
RUN apt-get update
|
||||||
RUN apt-get upgrade -y
|
RUN apt-get upgrade -y
|
||||||
|
|
||||||
RUN apt-get install -y curl ;\
|
RUN apt-get install -y curl
|
||||||
curl -s https://go.googlecode.com/files/go1.1.2.linux-amd64.tar.gz | tar -v -C /opt -xz ;\
|
RUN curl -s https://go.googlecode.com/files/go1.2.linux-amd64.tar.gz | tar -v -C /opt -xz ;\
|
||||||
cp -a /opt/go/* /usr/local/ ;\
|
cp -a /opt/go/* /usr/local/ ;\
|
||||||
rm -rf /opt/go ;\
|
rm -rf /opt/go;
|
||||||
#RUN
|
|
||||||
|
|
||||||
ENV GOROOT /usr/local/
|
ENV GOROOT /usr/local/
|
||||||
|
|
||||||
ADD . /app/
|
ADD . /app/
|
||||||
|
|
||||||
WORKDIR /app/
|
WORKDIR /app/
|
||||||
|
|
||||||
RUN go build dockerui.go
|
RUN go build dockerui.go
|
||||||
|
|
||||||
EXPOSE 9000
|
EXPOSE 9000
|
||||||
ENTRYPOINT ["./dockerui"]
|
ENTRYPOINT ["./dockerui"]
|
19
README.md
19
README.md
|
@ -1,4 +1,4 @@
|
||||||
##DockerUI
|
## DockerUI
|
||||||
|
|
||||||

|

|
||||||
DockerUI is a web interface to interact with the Remote API. The goal is to provide a pure client side implementation so it is effortless to connect and manage docker. This project is not complete and is still under heavy development.
|
DockerUI is a web interface to interact with the Remote API. The goal is to provide a pure client side implementation so it is effortless to connect and manage docker. This project is not complete and is still under heavy development.
|
||||||
|
@ -13,12 +13,12 @@ DockerUI is a web interface to interact with the Remote API. The goal is to pro
|
||||||
### Container Quickstart
|
### Container Quickstart
|
||||||
|
|
||||||
* Run your docker daemon with the following options:
|
* Run your docker daemon with the following options:
|
||||||
* `docker -d -H="0.0.0.0:4243" -api-enable-cors`
|
* `docker -d -H="0.0.0.0:4243" -api-enable-cors`
|
||||||
* `docker run -d -p 80:9000 crosbymichael/dockerui -e="http://<dockerd host ip>:4243"`
|
* `docker run -d -p 80:9000 crosbymichael/dockerui -e="http://<dockerd host ip>:4243"`
|
||||||
* Open your browser to `http://<dockerd host ip>`
|
* Open your browser to `http://<dockerd host ip>`
|
||||||
|
|
||||||
|
|
||||||
###Setup
|
### Setup
|
||||||
1. Make sure that you are running dockerd ( docker -d ) with the -H and [-api-enable-cors](http://docs.docker.io/en/latest/api/docker_remote_api_v1.2/#cors-requests) so that the UI can make requests to the Remote API.
|
1. Make sure that you are running dockerd ( docker -d ) with the -H and [-api-enable-cors](http://docs.docker.io/en/latest/api/docker_remote_api_v1.2/#cors-requests) so that the UI can make requests to the Remote API.
|
||||||
|
|
||||||
|
|
||||||
|
@ -37,14 +37,21 @@ DockerUI is a web interface to interact with the Remote API. The goal is to pro
|
||||||
5. Everything should be good to go, if you experience any issues please report them on this repository.
|
5. Everything should be good to go, if you experience any issues please report them on this repository.
|
||||||
|
|
||||||
|
|
||||||
###Stack
|
### Connect via a unix socket
|
||||||
|
If you want to connect to docker via the unix socket you can pass the socket path to the `-e` variable. If you are running dockerui in a container you can bind mount the unix socket into the container.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
docker run -d -p 9000:9000 -v /var/run/docker.sock:/docker.sock dockerui -e /docker.sock
|
||||||
|
```
|
||||||
|
|
||||||
|
### Stack
|
||||||
* Angular.js
|
* Angular.js
|
||||||
* Flatstrap ( Flat Twitter Bootstrap )
|
* Flatstrap ( Flat Twitter Bootstrap )
|
||||||
* Spin.js
|
* Spin.js
|
||||||
* Ace editor
|
* Ace editor
|
||||||
|
|
||||||
|
|
||||||
###Todo:
|
### Todo:
|
||||||
* Multiple endpoints
|
* Multiple endpoints
|
||||||
* Full repository support
|
* Full repository support
|
||||||
* Search
|
* Search
|
||||||
|
@ -53,7 +60,7 @@ DockerUI is a web interface to interact with the Remote API. The goal is to pro
|
||||||
* Authentication and Authorization
|
* Authentication and Authorization
|
||||||
|
|
||||||
|
|
||||||
###License - MIT
|
### License - MIT
|
||||||
The DockerUI code is licensed under the MIT license. Flatstrap(bootstrap) is licensed under the Apache License v2.0 and Angular.js is licensed under MIT.
|
The DockerUI code is licensed under the MIT license. Flatstrap(bootstrap) is licensed under the Apache License v2.0 and Angular.js is licensed under MIT.
|
||||||
|
|
||||||
|
|
||||||
|
|
68
dockerui.go
68
dockerui.go
|
@ -2,10 +2,13 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
"io"
|
||||||
"log"
|
"log"
|
||||||
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -14,20 +17,69 @@ var (
|
||||||
assets = flag.String("a", ".", "Path to the assets")
|
assets = flag.String("a", ".", "Path to the assets")
|
||||||
)
|
)
|
||||||
|
|
||||||
func createHandler(dir string, dockerEndpoint string) http.Handler {
|
type UnixHandler struct {
|
||||||
mux := http.NewServeMux()
|
path string
|
||||||
|
}
|
||||||
|
|
||||||
fileHandler := http.FileServer(http.Dir(dir))
|
func (h *UnixHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
u, err := url.Parse(dockerEndpoint)
|
conn, err := net.Dial("unix", h.path)
|
||||||
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
log.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c := httputil.NewClientConn(conn, nil)
|
||||||
|
defer c.Close()
|
||||||
|
|
||||||
|
res, err := c.Do(r)
|
||||||
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusInternalServerError)
|
||||||
|
log.Println(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer res.Body.Close()
|
||||||
|
|
||||||
|
copyHeader(w.Header(), res.Header)
|
||||||
|
if _, err := io.Copy(w, res.Body); err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func copyHeader(dst, src http.Header) {
|
||||||
|
for k, vv := range src {
|
||||||
|
for _, v := range vv {
|
||||||
|
dst.Add(k, v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func createTcpHandler(e string) http.Handler {
|
||||||
|
u, err := url.Parse(e)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
reverseProxy := httputil.NewSingleHostReverseProxy(u)
|
return httputil.NewSingleHostReverseProxy(u)
|
||||||
|
}
|
||||||
|
|
||||||
mux.Handle("/dockerapi/", http.StripPrefix("/dockerapi", reverseProxy))
|
func createUnixHandler(e string) http.Handler {
|
||||||
|
return &UnixHandler{e}
|
||||||
|
}
|
||||||
|
|
||||||
|
func createHandler(dir string, e string) http.Handler {
|
||||||
|
var (
|
||||||
|
mux = http.NewServeMux()
|
||||||
|
fileHandler = http.FileServer(http.Dir(dir))
|
||||||
|
h http.Handler
|
||||||
|
)
|
||||||
|
|
||||||
|
if strings.Contains(e, "http") {
|
||||||
|
h = createTcpHandler(e)
|
||||||
|
} else {
|
||||||
|
h = createUnixHandler(e)
|
||||||
|
}
|
||||||
|
|
||||||
|
mux.Handle("/dockerapi/", http.StripPrefix("/dockerapi", h))
|
||||||
mux.Handle("/", fileHandler)
|
mux.Handle("/", fileHandler)
|
||||||
|
|
||||||
return mux
|
return mux
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue