Compare commits
9 Commits
b58ea6b813
...
initial_fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d22de35b7a | ||
|
|
c48882e605 | ||
|
|
5789934db9 | ||
|
|
2255d759ec | ||
|
|
37a3395e7c | ||
|
|
d07cfe8089 | ||
|
|
a26863e74f | ||
|
|
37e8224369 | ||
|
|
f17bd2af08 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -94,3 +94,4 @@ ENV/
|
|||||||
# Rope project settings
|
# Rope project settings
|
||||||
.ropeproject
|
.ropeproject
|
||||||
|
|
||||||
|
/.idea
|
||||||
|
|||||||
13
README.md
13
README.md
@@ -1,2 +1,15 @@
|
|||||||
# docker_flask
|
# docker_flask
|
||||||
|
|
||||||
|
|
||||||
|
## Run
|
||||||
|
pip install -r requirements.txt
|
||||||
|
set FLASK_APP=index.py
|
||||||
|
set FLASK_DEBUG=1
|
||||||
|
flask run -p 5001
|
||||||
|
|
||||||
|
or
|
||||||
|
pip install -r requirements.txt
|
||||||
|
python index.py
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
14
index.py
14
index.py
@@ -5,6 +5,7 @@ import re
|
|||||||
import unidecode
|
import unidecode
|
||||||
import datetime
|
import datetime
|
||||||
import base64
|
import base64
|
||||||
|
import json
|
||||||
|
|
||||||
#
|
#
|
||||||
# from flask_wtf import FlaskForm
|
# from flask_wtf import FlaskForm
|
||||||
@@ -67,7 +68,8 @@ def images_all_action(client_name):
|
|||||||
def image_action(client_name, image_id):
|
def image_action(client_name, image_id):
|
||||||
if client_name in clients:
|
if client_name in clients:
|
||||||
image = clients[client_name].images.get(image_id)
|
image = clients[client_name].images.get(image_id)
|
||||||
return render_template('image.html', image=image, client_name=client_name)
|
return render_template('image.html', image=image, image_attributes=json.dumps(image.attrs, indent=4),
|
||||||
|
client_name=client_name)
|
||||||
else:
|
else:
|
||||||
flash('Client name \'%s\' not found' % client_name)
|
flash('Client name \'%s\' not found' % client_name)
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
@@ -184,7 +186,12 @@ def containers_all_action(client_name):
|
|||||||
def container_action(client_name, short_id=None):
|
def container_action(client_name, short_id=None):
|
||||||
if client_name in clients:
|
if client_name in clients:
|
||||||
container = clients[client_name].containers.get(short_id)
|
container = clients[client_name].containers.get(short_id)
|
||||||
return render_template('container.html', container=container, client_name=client_name)
|
# parsed = json.loads(container.attrs)
|
||||||
|
|
||||||
|
# print()
|
||||||
|
|
||||||
|
return render_template('container.html', container=container, client_name=client_name,
|
||||||
|
container_attributes=json.dumps(container.attrs, indent=4))
|
||||||
else:
|
else:
|
||||||
flash('Client name \'%s\' not found' % client_name)
|
flash('Client name \'%s\' not found' % client_name)
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
@@ -380,5 +387,6 @@ def slugify(text):
|
|||||||
|
|
||||||
app.secret_key = b'\xd7:o\\\xaayFe\x1ey\x08m9\xe4\xbc!\xee\x0e>\xd1Z\x99-\xbb'
|
app.secret_key = b'\xd7:o\\\xaayFe\x1ey\x08m9\xe4\xbc!\xee\x0e>\xd1Z\x99-\xbb'
|
||||||
|
|
||||||
|
# http://flask.pocoo.org/snippets/133/ @TODO
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(host="0.0.0.0", port=5002, debug=True, threaded=True)
|
app.run(host="0.0.0.0", port=5001, debug=True, threaded=True)
|
||||||
|
|||||||
17
requirements.txt
Normal file
17
requirements.txt
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
certifi==2018.1.18
|
||||||
|
chardet==3.0.4
|
||||||
|
click==6.7
|
||||||
|
docker==3.1.4
|
||||||
|
docker-pycreds==0.2.2
|
||||||
|
Flask==0.12.2
|
||||||
|
idna==2.6
|
||||||
|
itsdangerous==0.24
|
||||||
|
Jinja2==2.10
|
||||||
|
MarkupSafe==1.0
|
||||||
|
pypiwin32==219
|
||||||
|
requests==2.18.4
|
||||||
|
six==1.11.0
|
||||||
|
Unidecode==1.0.22
|
||||||
|
urllib3==1.22
|
||||||
|
websocket-client==0.47.0
|
||||||
|
Werkzeug==0.14.1
|
||||||
@@ -62,9 +62,9 @@ min-width: 140px;
|
|||||||
table tbody tr:nth-child(2n+1) {
|
table tbody tr:nth-child(2n+1) {
|
||||||
background-color: #f9f9f9; }
|
background-color: #f9f9f9; }
|
||||||
|
|
||||||
h1 { font-size: 2.75em; margin: 16px 32px 16px 32px;}
|
h1 { font-size: 2.75em; margin: 16px 32px 16px 0;}
|
||||||
h2 { font-size: 2em; margin: 16px 32px 16px 16px;}
|
h2 { font-size: 2em; margin: 16px 32px 16px 0;}
|
||||||
h3 { font-size: 1.5em; margin: 16px 32px 16px 32px;}
|
h3 { font-size: 1.5em; margin: 16px 32px 16px 0;}
|
||||||
|
|
||||||
a {color: dodgerblue; text-decoration: none; }
|
a {color: dodgerblue; text-decoration: none; }
|
||||||
a:hover { text-decoration: underline; }
|
a:hover { text-decoration: underline; }
|
||||||
@@ -110,4 +110,18 @@ padding: 5px 15px;
|
|||||||
.details__entrypoint { display: inline-block; width: 210px; }
|
.details__entrypoint { display: inline-block; width: 210px; }
|
||||||
.details__image { display: inline-block; }
|
.details__image { display: inline-block; }
|
||||||
|
|
||||||
.details__more-info {display: none; }
|
.details__more-info { margin: 5px 10px; }
|
||||||
|
.more-info__ports { }
|
||||||
|
.more-info__ports--line {
|
||||||
|
display: list-item;
|
||||||
|
list-style-position: inside;
|
||||||
|
margin: 8px 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container_attribute, .image_attribute {
|
||||||
|
|
||||||
|
}
|
||||||
|
.container_attribute-details, .image_attribute-details {
|
||||||
|
white-space: pre;
|
||||||
|
line-height: 1.1em;
|
||||||
|
}
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
{% extends "layout.html" %}
|
{% extends "layout.html" %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
|
||||||
<h1><a href="/">Dashboard</a> » {{ client_name }} » <a href="/{{ client_name }}/containers">Containers</a> » {{ container.name }}</h1>
|
<h1><a href="/">Dashboard</a> » {{ client_name }} » <a href="/{{ client_name }}/containers">Containers</a>
|
||||||
|
» {{ container.name }}</h1>
|
||||||
|
|
||||||
<form action="{{ url_for('rename_container', client_name=client_name) }}" method="post">
|
<form action="{{ url_for('rename_container', client_name=client_name) }}" method="post">
|
||||||
<p><input type="text" name="name" size="60" value="{{ container.name }}"><!--
|
<p><input type="text" name="name" size="60" value="{{ container.name }}"><!--
|
||||||
@@ -10,8 +11,7 @@
|
|||||||
</form>
|
</form>
|
||||||
|
|
||||||
<h2>Details</h2>
|
<h2>Details</h2>
|
||||||
<pre>
|
<div class="container_attribute">
|
||||||
{{ container.attrs|pprint }}
|
<div class="container_attribute-details">{{ container_attributes }}</div>
|
||||||
|
</div>
|
||||||
</pre>
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
{% block body %}
|
{% block body %}
|
||||||
|
|
||||||
|
|
||||||
<h1><a href="/">Dashboard</a> » {{ client_name }} » Containers</h1>
|
<h1><a href="/">Dashboard</a> » {{ client_name }} » <a href="/{{ client_name }}/containers">Containers</a></h1>
|
||||||
|
|
||||||
|
|
||||||
<a class="button--link" href="/{{ client_name }}/containers/all">All Containers</a>
|
<a class="button--link" href="/{{ client_name }}/containers/all">All Containers</a>
|
||||||
@@ -28,26 +28,11 @@
|
|||||||
container.attrs.Config.Labels['com.docker.compose.project'] }}</a></h2>
|
container.attrs.Config.Labels['com.docker.compose.project'] }}</a></h2>
|
||||||
{% endif%}
|
{% endif%}
|
||||||
|
|
||||||
<!--<table>-->
|
|
||||||
<!--<thead>-->
|
|
||||||
<!--<tr>-->
|
|
||||||
<!--<th>COMPOSE PROJECT</th>-->
|
|
||||||
<!--<th>CONTAINER ID</th>-->
|
|
||||||
<!--<th>NAME</th>-->
|
|
||||||
<!--<th>COMMAND</th>-->
|
|
||||||
<!--<th>CREATED</th>-->
|
|
||||||
<!--<th>STATUS</th>-->
|
|
||||||
<!--<th>PORTS</th>-->
|
|
||||||
<!--<th>IMAGE</th>-->
|
|
||||||
<!--</tr>-->
|
|
||||||
<!--</thead>-->
|
|
||||||
<!--<tbody>-->
|
|
||||||
|
|
||||||
|
|
||||||
<div class="details">
|
<div class="details">
|
||||||
<div>
|
<div>
|
||||||
<div class="details__status details__status--{{ container.status }}">{{ container.status }}</div>
|
<div class="details__status details__status--{{ container.status }}">{{ container.status }}
|
||||||
<div class="details__name"><a class="button--link"
|
</div><div
|
||||||
|
class="details__name"><a class="button--link"
|
||||||
href="/{{ client_name }}/containers/id/{{ container.short_id }}">{{
|
href="/{{ client_name }}/containers/id/{{ container.short_id }}">{{
|
||||||
container.name
|
container.name
|
||||||
}}</a></div>
|
}}</a></div>
|
||||||
@@ -61,17 +46,15 @@
|
|||||||
<div class="details__more-info">
|
<div class="details__more-info">
|
||||||
<div class="more-info__ports">
|
<div class="more-info__ports">
|
||||||
{% for port in container.attrs['NetworkSettings']['Ports'] %}
|
{% for port in container.attrs['NetworkSettings']['Ports'] %}
|
||||||
{{ port }}
|
|
||||||
{% if container.attrs['NetworkSettings']['Ports'][port] is not none %}
|
{% if container.attrs['NetworkSettings']['Ports'][port] is not none %}
|
||||||
|
|
||||||
{% if container.attrs['NetworkSettings']['Ports'][port] is not none and
|
{% if container.attrs['NetworkSettings']['Ports'][port] is not none and
|
||||||
container.attrs['NetworkSettings']['Ports'][port]|length > 0 %}
|
container.attrs['NetworkSettings']['Ports'][port]|length > 0 %}
|
||||||
{% for port_exposed in container.attrs['NetworkSettings']['Ports'][port] %}
|
{% for port_exposed in container.attrs['NetworkSettings']['Ports'][port] %}
|
||||||
->{{ port_exposed['HostIp'] }}:{{ port_exposed['HostPort'] }}
|
<span class="more-info__ports--line">{{ port }} -> {{ port_exposed['HostIp'] }}:{{ port_exposed['HostPort'] }}</span>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -80,17 +63,15 @@
|
|||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="details__controll">
|
<div class="details__controll">
|
||||||
<a class="button--link" href="/{{ client_name }}/containers/log/{{ container.short_id }}">log</a>
|
<a class="button--link" href="/{{ client_name }}/containers/log/{{ container.short_id }}">log
|
||||||
<a class="button--link" href="/{{ client_name }}/containers/export/{{ container.short_id }}">export</a>
|
</a><a class="button--link" href="/{{ client_name }}/containers/export/{{ container.short_id }}">export
|
||||||
{% if (container.status == 'exited') or (container.status == 'created') %}
|
</a>{% if (container.status == 'exited') or (container.status == 'created') %}<a class="button--link"
|
||||||
<a class="button--link" href="/{{ client_name }}/containers/start/{{ container.short_id }}">start</a>
|
href="/{{ client_name }}/containers/start/{{ container.short_id }}">start
|
||||||
<a class="button--link" href="/{{ client_name }}/containers/remove/{{ container.short_id }}">remove</a>
|
</a><a class="button--link" href="/{{ client_name }}/containers/remove/{{ container.short_id }}">remove</a>
|
||||||
{% endif %}
|
{% endif %}{% if container.status == 'running' %}
|
||||||
|
<a class="button--link" href="/{{ client_name }}/containers/stop/{{ container.short_id }}">stop
|
||||||
{% if container.status == 'running' %}
|
</a><a class="button--link" href="/{{ client_name }}/containers/restart/{{ container.short_id }}">restart
|
||||||
<a class="button--link" href="/{{ client_name }}/containers/stop/{{ container.short_id }}">stop</a>
|
</a><a class="button--link" href="/{{ client_name }}/containers/top/{{ container.short_id }}">top</a>
|
||||||
<a class="button--link" href="/{{ client_name }}/containers/restart/{{ container.short_id }}">restart</a>
|
|
||||||
<a class="button--link" href="/{{ client_name }}/containers/top/{{ container.short_id }}">top</a>
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
}} {% endif %}</h1>
|
}} {% endif %}</h1>
|
||||||
|
|
||||||
<h2>Details</h2>
|
<h2>Details</h2>
|
||||||
<pre>
|
<div class="image_attribute">
|
||||||
{{ image.attrs | pprint }}
|
<div class="image_attribute-details">{{ image_attributes }}</div>
|
||||||
</pre>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
{% block body %}
|
{% block body %}
|
||||||
|
|
||||||
|
|
||||||
<h1><a href="/">Dashboard</a> » {{ client_name }} » Images</h1>
|
<h1><a href="/">Dashboard</a> » {{ client_name }} » <a href="/{{ client_name }}/images">Images</a></h1>
|
||||||
|
|
||||||
|
|
||||||
<a class="button--link" href="/{{ client_name }}/images/dangling">Dangling Images</a>
|
<a class="button--link" href="/{{ client_name }}/images/dangling">Dangling Images</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user