diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..0791152 Binary files /dev/null and b/.DS_Store differ diff --git a/Common_user/.DS_Store b/Common_user/.DS_Store new file mode 100644 index 0000000..c5ad272 Binary files /dev/null and b/Common_user/.DS_Store differ diff --git a/Common_user/2021_07_02/image/miruware-logo.jpg b/Common_user/2021-07-02/image/miruware-logo.jpg similarity index 100% rename from Common_user/2021_07_02/image/miruware-logo.jpg rename to Common_user/2021-07-02/image/miruware-logo.jpg diff --git a/Common_user/2021_07_02/image/miruware_logo.ico b/Common_user/2021-07-02/image/miruware_logo.ico similarity index 100% rename from Common_user/2021_07_02/image/miruware_logo.ico rename to Common_user/2021-07-02/image/miruware_logo.ico diff --git a/Common_user/2021_07_02/image/miruware_logo.png b/Common_user/2021-07-02/image/miruware_logo.png similarity index 100% rename from Common_user/2021_07_02/image/miruware_logo.png rename to Common_user/2021-07-02/image/miruware_logo.png diff --git a/Common_user/2021_07_02/run.py b/Common_user/2021-07-02/run.py similarity index 100% rename from Common_user/2021_07_02/run.py rename to Common_user/2021-07-02/run.py diff --git a/Common_user/2022-08-16/image/miruware-logo.jpg b/Common_user/2022-08-16/image/miruware-logo.jpg new file mode 100644 index 0000000..2db2bb8 Binary files /dev/null and b/Common_user/2022-08-16/image/miruware-logo.jpg differ diff --git a/Common_user/2022-08-16/image/miruware_logo.ico b/Common_user/2022-08-16/image/miruware_logo.ico new file mode 100644 index 0000000..4d928f4 Binary files /dev/null and b/Common_user/2022-08-16/image/miruware_logo.ico differ diff --git a/Common_user/2022-08-16/image/miruware_logo.png b/Common_user/2022-08-16/image/miruware_logo.png new file mode 100644 index 0000000..c924da4 Binary files /dev/null and b/Common_user/2022-08-16/image/miruware_logo.png differ diff --git a/Common_user/2022-08-16/run.py b/Common_user/2022-08-16/run.py new file mode 100644 index 0000000..2212a24 --- /dev/null +++ b/Common_user/2022-08-16/run.py @@ -0,0 +1,437 @@ +import os +import time +from tkinter import ttk +from tkinter import * +from tkinter.ttk import * + +# Docker image list preprocessing +def docker_preprocessing(): + + os.system(str("docker images > ./docker_image_list")) + + f = open("./docker_image_list", "rt", encoding="utf-8") + image = f.readlines() + f.close() + #print(image) + + image = "".join(image).split("\n") + #image = ",".join(image).split(" ") + #print(image[1]) + + var = 0 + var_list = [] + + for i in range(len(image)): + #print(i) + var = "".join(image[i]).split(" ") + #print(var) + var_list.append(var) + + + var_list = var_list[1:-1] + + #print(var_list) + + image_name = [] + tag = [] + image_id = [] + image_list = [] + + idx = 0 + for i in range(len(var_list)): + temp=[] + temp = ' '.join(var_list[i]).split() + #print("temp : ", temp) + image_name.append(temp[0]) + tag.append(temp[1]) + image_id.append(temp[2]) + image_list.append(temp[0]+ ':' +temp[1]) + #print(" ") + #print(str(idx) + " : " + temp[0]+ ':' +temp[1]) + image_full_name = str(temp[0]) + ":" + str(temp[1]) + lb1.insert(idx, str(image_full_name)) + idx += 1 + + os.system("rm ./docker_image_list") + + #return image_list + + + """ + print('image_name : ', image_name) + print('tag : ', tag) + print('image_id : ', image_id) + """ + #print('image list : ', image_list) + + #print("docker_preprocessing complete") + + # GPU 사용 가능 개수 확인 함수 +def gpu_check(): + #os.system(str(ssh_connect.format(**data)) + "nvidia-smi | grep MiB | grep % > /home/" + user_id + "/flask/data/max_gpu_avail") + current_path = str(os.popen("pwd").read()) + current_path = current_path.rstrip('\n') + os.system("nvidia-smi | grep MiB | grep % > ./max_gpu_avail") + #os.system(scp_connect.format(**data) + "max_gpu_avail ./data/") + f = open("./max_gpu_avail", "rt", encoding="utf-8") + max_gpu_avail_temp = f.readlines() + f.close() + max_gpu_avail = str(len(max_gpu_avail_temp)) + os.system("rm ./max_gpu_avail") + #print('max_gpu_avail : ',max_gpu_avail) + #print("gpu_avail() complete") + + if(int(max_gpu_avail)>=1): + gpu_num_list.append(0) + for i in range(len(max_gpu_avail)): + gpu_num_list.append(i+1) + else: + gpu_num_list.append(0) + +def select_image(): + idx = lb1.curselection() + ent1.delete(0,len(ent1.get())) + ent1.insert(0, str(lb1.get(idx))) + +def undo_select_image(): + ent1.delete(0,len(ent1.get())) + +def container_name_check(): + user_name = str(os.popen("whoami").read()) + user_name = user_name.rstrip('\n') + #print(user_name) + + os.system(str("docker ps -a | grep -i $(whoami) > ./docker_container_name")) + + f = open("./docker_container_name", "rt", encoding="utf-8") + name = f.readlines() + f.close() + os.system("rm ./docker_container_name") + + name = "".join(name).split("\n") + + var = 0 + var_list = [] + + for i in range(len(name)): + #print(i) + var = "".join(name[i]).split(" ") + #print(var) + var_list.append(var) + + var_list = var_list[:-1] + + #print(var_list) + + name_list = [] + for i in range(len(var_list)): + temp=[] + temp = ' '.join(var_list[i]).split() + #print(temp[-1]) + name_list.append(temp[-1]) + + #print(name_list) + + idx = 0 + container_name = "" + #for i in range(len(name_list)): + while True: + idx_1 = 0 + idx_2 = 0 + temp = user_name + str(idx) + idx += 1 + #print(len(name_list)) + if(len(name_list) == 0): + container_name = temp + break + for j in name_list: + if(str(temp) == j): + #print("name_list :", j, "temp : ", temp) + continue + else: + idx_1 += 1 + + if(idx_1 == len(name_list)): + idx_2 += 1 + container_name = temp + #print(container_name) + if (idx_2 == 1): + break + return container_name + +def cancle_button(): + ent1.delete(0,len(ent1.get())) + r_ent_name.delete(0,len(r_ent_name.get())) + r_ent_disk_container.delete(0,len(r_ent_disk_container.get())) + r_ent_disk_local.delete(0,len(r_ent_disk_local.get())) + r_ent_port_container.delete(0,len(r_ent_port_container.get())) + r_ent_port_local.delete(0,len(r_ent_port_local.get())) + r_ent_command.delete(0,len(r_ent_command.get())) + +def refresh_image(): + lb1.delete(0,END) + docker_preprocessing() + +def summit_button(): + # rm + rm_command="" + if(int(check_rm.get())==1): + rm_command="--rm" + #print(rm_command) + + # gpu + gpu_command="" + value = r_combo_gpu.current() + #print(value) + if(str(value) != "0"): + gpu_command = "--gpus " + str(value) + #print(gpu_command) + + # name + container_name = str(r_ent_name.get()) + container_name_command = "--name " + container_name + #print(container_name_command) + + # mount + if(int(check_mount.get()==1)): + mount_path_local = str(r_ent_disk_local.get()) + mount_path_container = str(r_ent_disk_container.get()) + mount_path_command = "-v " + mount_path_local + ":" + mount_path_container + #print(mount_path_command) + else: + mount_path_command="" + #print("Do not use mount") + pass + + # port + if(int(check_port_foward.get()==1)): + port_foward_local = str(r_ent_port_local.get()) + port_foward_container = str(r_ent_port_container.get()) + port_foward_command = "-p " + port_foward_local + ":" + port_foward_container + #print(port_foward_command) + else: + port_foward_command="" + #print("Do not use port foward") + pass + + # command + command = str(r_ent_command.get()) + #print(command) + + # image + image_name = str(ent1.get()) + #print(image_name) + + time.sleep(1) + win.destroy() + + if(str(value) != "0"): + docker_run_command = "nvidia-docker run -ti" + " " + rm_command + " " \ + + gpu_command + " " + container_name_command + " " \ + + mount_path_command + " " + port_foward_command + " " \ + + image_name + " " + command + else: + docker_run_command = "docker run -ti" + " " + rm_command + " " \ + + gpu_command + " " + container_name_command + " " \ + + mount_path_command + " " + port_foward_command + " " \ + + image_name + " " + command + + + #print(docker_run_command) + + os.system(docker_run_command) + + + + +################################################################### + +win = Tk() +win.geometry("1200x600") +win.title("MW Docker") +win.option_add("*Font", "Arial 15") +win.resizable(False, False) + + + +# 로고 +lab_img = Label(win) +current_path = str(os.popen("pwd").read()) +current_path = current_path.rstrip('\n') +image_path = current_path + "/image/miruware_logo.png" +img = PhotoImage(file = image_path, master=win) +img = img.subsample(2) +lab_img.config(image=img) +lab_img.place(x=900, y=20) + + + + +# 라벨 +lab1 = Label(win) +lab1.place(x=20, y=10, width=490, height=30) +lab1.config(text="Docker images") + + +# 리스트박스 +lb1 = Listbox(win) +docker_preprocessing() +lb1.place(x=20, y=50, width=470, height=360) + +xscrollbar = Scrollbar(win, orient="horizontal") +xscrollbar.config(command=lb1.xview) +xscrollbar.place(x=20, y=410, width=470, height=20) + +yscrollbar = Scrollbar(win, orient="vertical") +yscrollbar.config(command=lb1.yview) +yscrollbar.place(x=490, y=50, width=20, height=360) + + +# Button +up_btn = Button(win, text="Undo") +up_btn.config(command=undo_select_image) +up_btn.place(x=70, y=470, width=160, height=30) + +down_btn = Button(win, text="Select") +down_btn.config(command=select_image) +down_btn.place(x=280, y=470, width=160, height=30) + + +# 선택된 이미지 이름 +ent1 = Entry(win) +ent1.place(x=20, y=530, width=490, height=30) +#ent1.config(text="test") + + +# 새로고침 버튼 +refresh_button = Button(win, text="Reload") +refresh_button.config(command=refresh_image) +refresh_button.place(x=350, y=20, width=160, height=25) + + +# Right (Selector) +#--------------------------------------------------------------- + +# --rm option +check_rm = IntVar() +r_check_rm = Checkbutton(win, variable=check_rm, onvalue=1, offvalue=0) +r_check_rm.config(text="Use --rm option ") +r_check_rm.place(x=530, y=80, width=315, height=30) + + +# GPU +r_lab_gpu = Label(win) +r_lab_gpu.place(x=530, y=130, width=230, height=30) +r_lab_gpu.config(text="GPU Count ") + +#gpu_num_list = [1,2,3,4,5,6,7,8] +gpu_num_list=[] +gpu_check() +r_combo_gpu = ttk.Combobox(win) +r_combo_gpu.config(value = gpu_num_list) +r_combo_gpu.place(x=530, y=160, width=230, height=30) + + + + + + +# Container Name +container_name = container_name_check() + +r_lab_name = Label(win) +r_lab_name.place(x=780, y=130, width=400, height=30) +r_lab_name.config(text="Container Name(Do not use space)") + +r_ent_name = Entry(win) +r_ent_name.insert(0, str(container_name)) +r_ent_name.place(x=780, y=160, width=400, height=30) + + + + + + +# Disk mount +check_mount = IntVar() +r_check_disk = Checkbutton(win, variable=check_mount, onvalue=1, offvalue=0) +r_check_disk.config(text="Use DIsk Mount ") +r_check_disk.place(x=530, y=220, width=315, height=30) + +r_lab_disk_local = Label(win) +r_lab_disk_local.place(x=530, y=250, width=315, height=30) +r_lab_disk_local.config(text="Local Path (Absolute Path)") + +r_ent_disk_local = Entry(win) +r_ent_disk_local.place(x=530, y=280, width=315, height=30) + +r_lab_disk_container = Label(win) +r_lab_disk_container.place(x=865, y=250, width=315, height=30) +r_lab_disk_container.config(text="Container Path (Absolute Path)") + +r_ent_disk_container = Entry(win) +r_ent_disk_container.place(x=865, y=280, width=315, height=30) + + + + + +# Port Fowarding +check_port_foward = IntVar() +r_check_port = Checkbutton(win, variable=check_port_foward, onvalue=1, offvalue=0) +r_check_port.config(text="Use Port Fowarding ") +r_check_port.place(x=530, y=330, width=315, height=30) + +r_lab_port_local = Label(win) +r_lab_port_local.place(x=530, y=360, width=315, height=30) +r_lab_port_local.config(text="Local Port") + +r_ent_port_local = Entry(win) +r_ent_port_local.place(x=530, y=390, width=315, height=30) + +r_lab_port_container = Label(win) +r_lab_port_container.place(x=865, y=360, width=315, height=30) +r_lab_port_container.config(text="Container Port") + +r_ent_port_container = Entry(win) +r_ent_port_container.place(x=865, y=390, width=315, height=30) + + +# command +r_lab_command = Label(win) +r_lab_command.place(x=600, y=460, width=315, height=30) +r_lab_command.config(text="Command :") + +r_ent_command = Entry(win) +r_ent_command.insert(0,"bash") +r_ent_command.place(x=720, y=460, width=400, height=30) + + + + + +# Button +cancle_btn = Button(win, text="Reset") +cancle_btn.config(command=cancle_button) +cancle_btn.place(x=950, y=520, width=100, height=50) + + +summit_btn = Button(win, text="Summit") +summit_btn.config(command=summit_button) +summit_btn.place(x=1070, y=520, width=100, height=50) + + + + +#-------------------------------------------- +# Copyright +copyright = Label( + win, + font=("Helvetica", 9)) +copyright.config(text="Made By Suseong,Yang Email : tntjd5596@miruware.com 2021.08.16") +copyright.place(x=700, y=570, width=500, height=30) + + + +win.mainloop() + diff --git a/Common_user/run.py b/Common_user/run.py index c1ce7b6..2212a24 100644 --- a/Common_user/run.py +++ b/Common_user/run.py @@ -256,7 +256,10 @@ def summit_button(): # 로고 lab_img = Label(win) -img = PhotoImage(file = "/home/miruware/yss/test/miruware_logo.png", master=win) +current_path = str(os.popen("pwd").read()) +current_path = current_path.rstrip('\n') +image_path = current_path + "/image/miruware_logo.png" +img = PhotoImage(file = image_path, master=win) img = img.subsample(2) lab_img.config(image=img) lab_img.place(x=900, y=20) @@ -425,7 +428,7 @@ def summit_button(): copyright = Label( win, font=("Helvetica", 9)) -copyright.config(text="Made By Suseong,Yang Email : tntjd5596@miruware.com 2021.07.06") +copyright.config(text="Made By Suseong,Yang Email : tntjd5596@miruware.com 2021.08.16") copyright.place(x=700, y=570, width=500, height=30) diff --git a/Docker GUI Controller.pdf b/Docker GUI Controller.pdf new file mode 100644 index 0000000..b8e8307 Binary files /dev/null and b/Docker GUI Controller.pdf differ diff --git a/README.md b/README.md index 3a27ecf..0132209 100644 --- a/README.md +++ b/README.md @@ -1 +1,222 @@ -# docker_gui_controller \ No newline at end of file +# Docker GUI Controller +* Requirements + * python3-tk Package + * Docker + * Ubuntu OS + +::tkinter install:: +```bash +$ sudo apt install python3-tk +``` + + +## Admin용 GUI Controller +--- + +### 실행 방법 +```bash +$ python ./docker_gui_controller/admin/run.py +``` + +[image:69E19AE1-E507-4FC6-9FBC-9D2CA6D63CCB-23049-00000159F2FC1760/스크린샷 2022-08-16 오전 11.47.11.png] + +### Image 관리 + +#### Docker pull +::Images 탭 에서 Pull 버튼 클릭:: +[image:01682EBA-1C45-479F-970B-4646342D586D-23049-0000015DAF044F3E/0B84BF5D-D16A-4A16-BBC2-3E8E5DFC17B3.png] + +::받아올 이미지 이름과 Tag를 입력 후 Summit 버튼 클릭:: +[image:8B9033B7-7715-49DD-BCB1-34D6B46E97B3-23049-0000015DD962C4CF/A3F5D06F-63E5-4F2C-B53D-3715778849FB.png] + +::터미널에서 이미지 Pull 진행 확인:: +[image:7A5989AA-74F6-4C40-BE25-10F72D5706DB-23049-0000015E48AD8FB0/0335231F-2C59-49F6-8E62-D7F180A4AE84.png] + +::Pull 완료된 이미지 확인:: +[image:EA299221-8489-4C90-834C-A13E83AC7A9F-23049-0000015E963D183E/0E247763-135C-464C-991A-2A6160502CA2.png] + + + +#### Docker tag +::Images 탭 에서 원하는 이미지 Select 한 이후 Tag 버튼 클릭:: +[image:DBD7970B-89E5-4AD4-B585-41B2DBEF1C70-23049-0000015F3AB75630/222452BE-EDF6-43FB-A903-276B9716DCFE.png] + +::생성할 이미지 이름과 Tag 를 입력 후 Summit 버튼 클릭:: +[image:2E3D095B-0D02-47CF-ABD5-CC60DA95DE86-23049-00000171F250FB4E/스크린샷 2022-08-16 오후 12.58.44.png] +[image:ED73ACB2-CE26-4AB0-B4FF-73385273C338-23049-0000015B1AE2711C/스크린샷 2022-08-16 오전 11.50.38.png] + +::이미지 생성 확인:: +[image:03DDC7CA-C896-4A4E-BE94-F120BDEC3BCC-23049-000001720CF8D43D/스크린샷 2022-08-16 오후 12.59.03.png] + + + + +#### 이미지 Push +::Images 탭 에서 원하는 이미지 Select 한 이후 Push 버튼 클릭:: +[image:A470E817-FC5A-424D-A6B3-B5A4FD4EC53D-23049-0000017937A6AEFE/DEA58421-BEC1-483F-AE6C-01FAA20D56A7.png] +[image:8E13DE06-F40D-4578-83C0-10478B6FB2F2-23049-00000160E70E8A66/619E4778-00AE-4E04-94FC-E3A67015CAE7.png] +[image:861A6A03-0562-474E-B921-CF0C0C3E45AA-23049-000001791EEC99B2/스크린샷 2022-08-16 오후 2.00.00.png] + +::이미지 업로드 확인:: +[image:ADAA4A22-73D2-4304-BF10-54F9CD25E2DD-23049-00000179C89D9852/617B36B7-20ED-4B17-AEC8-7CF95B40567D.png] + + + +#### 이미지 Remove +::Images 탭 에서 원하는 이미지 Select 한 이후 Remove 버튼 클릭:: +[image:49F77541-6BC4-48E4-A8E5-F2054A6E7D21-23049-0000017A13E434BA/08591D71-5483-4F70-B76B-68E677169D46.png] +[image:E6999986-462D-4939-BAD8-30E2BC4038F2-23049-0000017A3EDD018C/스크린샷 2022-08-16 오후 2.03.50.png] + +::이미지 삭제 확인:: +[image:943A2C3B-F24A-4EAF-A921-09FDF0D31783-23049-0000017A5CA6A7A4/2194EC0F-E446-4390-B57B-C1C0D0729A97.png] + + + + +### Container 관리 + +::예시를 위한 컨테이너 생성:: +```bash +$ docker run -d --name gui-test ubuntu:20.04 +``` + +::컨테이너 확인:: +[image:862A8375-D41C-4B35-990C-78F271B3D74F-23049-0000017BA1429DC7/6B14DF42-526C-4545-B150-251E1EA77493.png] + + +#### 컨테이너 Start +::Containers 탭 에서 원하는 컨테이너 Select 한 이후 Start 버튼 클릭:: +[image:1C843E64-2809-4D54-BE0D-7FA6949D3E7F-23049-0000017C32ACFE6A/E66DE98B-ED94-4C3A-8C07-7E6316757E32.png] +[image:F80E5FB0-E8EF-4BED-8015-AC347B2F352B-23049-0000017C44C0C38E/스크린샷 2022-08-16 오후 2.09.53.png] + +::컨테이너 Status 확인:: +[image:D7A21041-A478-4CB7-8BE1-C7053F92999F-23049-0000017C93B97D5B/594D6DD0-4874-4D11-90B8-346070CDF791.png] + + + +#### 컨테이너 Stop +::Containers 탭 에서 원하는 컨테이너 Select 한 이후 Stop 버튼 클릭:: +[image:C4F73ABA-A47E-40E3-A2CD-7AF45DFFD250-23049-0000017CD945E7BF/스크린샷 2022-08-16 오후 2.11.37.png] +[image:C45320A7-4896-4870-8EBF-972F94DAFF44-23049-0000017CEB5EDBA8/스크린샷 2022-08-16 오후 2.11.49.png] + +::컨테이너 Status 확인:: +[image:1C994B1B-A49B-44A3-B608-10CA5E5E82F7-23049-0000017D2A960738/23194930-B40A-4A1E-8608-24AA2513BE25.png] + + + +#### 컨테이너 Commit +::Containers 탭 에서 원하는 컨테이너 Select 한 이후 Commit 버튼 클릭:: +[image:8F8C32B6-B1B7-4270-BEA0-ECB3CDA51AFC-23049-0000017D69D6EE52/BE8179E9-8879-4601-ABC1-B2B7D6A81450.png] + +::커밋할 이미지 이름과 태그 입력 후 Summit 버튼 클릭:: +[image:FCC08BC4-5870-42D2-B1E4-EFEF73AD63C3-23049-0000017DB4E3BB71/스크린샷 2022-08-16 오후 2.14.09.png] +[image:9C216CB1-217B-4AA5-A502-4F6B6992D462-23049-0000017E2E38CF48/스크린샷 2022-08-16 오후 2.15.34.png] + +::Images 탭에서 커밋한 이미지 확인:: +[image:68268897-FC85-465F-B0FB-42D64F3039D9-23049-0000017E60B363C1/1091FD16-307E-4948-87AD-FB06FEBB4ED3.png] + + + +#### 컨테이너 삭제 +::Containers 탭 에서 원하는 컨테이너 Select 한 이후 Remove 버튼 클릭:: +[image:68813EE5-0F6C-440A-8FDB-42C5B296E159-23049-0000017EEB7EB2FB/073F44B1-9D87-4357-B38A-09A79DF291A5.png] + +::확인 단계에서 Summit 버튼 클릭:: +[image:617BE053-70A8-4869-94E6-29847544EBE8-23049-0000017F09843279/ECC71B02-A61A-441B-ACFF-C48A8F50064A.png] + +::컨테이너 삭제 확인:: +[image:93344796-CD52-4A7C-8BEF-C349BDB4B2D5-23049-0000017F3DAB6675/5FEAB16D-30B0-49C4-A5E6-20A454E4D599.png] + + + + + + + + +## User 용 GUI Controller +--- + +### 실행 방법 +```bash +$ python3 ./docker_gui_controller/Common_user/run.py +``` + +### 실행 예시 +[image:82AF2992-6CE6-41A7-9959-A6F2DA0D7941-23049-00000189F24DC6AC/스크린샷 2022-08-16 오후 2.50.41.png] + +::Docker images:: +* 사용할 이미지를 선택하여 Select 버튼 클릭 + +::—rm Option:: +* 컨테이너에 --rm 옵션을 사용할 시 체크박스 체크 + +::GPU Count:: +* 컨테이너에 사용할 GPU의 개수를 선택 +* 자동으로 사용 가능한 최대 개수를 제한함 +* CPU 만 사용할 경우 GPU Count를 0으로 선택 + +::Container Name:: +* 컨테이너의 이름을 지정 +* 코드 실행 시 계정명+Index 로 자동으로 이름이 겹치지 않게 지정됨 + +::Mount Option:: +* 컨테이너에 디스크를 마운트 할 경우 체크박스 체크 +* 로컬 디렉토리 경로와 컨테이너 디렉토리 경로를 입력하여 마운트 + +::Port Fowarding Option:: +* 컨테이너에 포트포워딩을 할 경우 체크박스 체크 +* 로컬 포트와 컨테이너 포트를 입력하여 포트포워딩 + +::Command:: +* 컨테이너 실행 시 실행할 Command를 입력 + + + +### 실행 결과 +[image:BC5DAE02-0D6E-4D3A-9393-55EBF26DDA6D-23049-0000018A0D535984/스크린샷 2022-08-16 오후 2.50.59.png] + +#### Mount 동작 확인 +::컨테이너에서 마운트 포인트에 aaa.txt 파일 생성:: +```bash +root@88d837e35a07:/# cd /mount_test && touch aaa.txt +root@88d837e35a07:/mount_test# ls +>>> aaa.txt mw_ost_tools yss-kubeconfig +``` + +::로컬 마운트 포인트에 파일 생성 확인:: +```bash +$ ls /home/yss +>>> aaa.txt mw_ost_tools yss-kubeconfig +``` + + + + + + + + + +## Trouble Shooting +--- + +### Docker 권한이 없는 경우 +```bash +Got permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.24/images/json": dial unix /var/run/docker.sock: connect: permission denied +``` + +Tool 을 사용하는 계정을 Docker 그룹에 추가하여 해결 + +```bash +$ sudo usermod -aG docker $USER +``` + + +### Nvidia driver 가 없는 경우 +```bash +sh: 1: nvidia-smi: not found +``` + +GPU 서버가 아닌 경우 무시해도 상관 없고 +GPU 서버인 경우 NVIDIA Driver 를 설치하여 해결 diff --git a/admin/.DS_Store b/admin/.DS_Store new file mode 100644 index 0000000..771679a Binary files /dev/null and b/admin/.DS_Store differ diff --git a/admin/2022-08-16/image/miruware-logo.jpg b/admin/2022-08-16/image/miruware-logo.jpg new file mode 100644 index 0000000..2db2bb8 Binary files /dev/null and b/admin/2022-08-16/image/miruware-logo.jpg differ diff --git a/admin/2022-08-16/image/miruware_logo.ico b/admin/2022-08-16/image/miruware_logo.ico new file mode 100644 index 0000000..4d928f4 Binary files /dev/null and b/admin/2022-08-16/image/miruware_logo.ico differ diff --git a/admin/2022-08-16/image/miruware_logo.png b/admin/2022-08-16/image/miruware_logo.png new file mode 100644 index 0000000..c924da4 Binary files /dev/null and b/admin/2022-08-16/image/miruware_logo.png differ diff --git a/admin/2022-08-16/run.py b/admin/2022-08-16/run.py new file mode 100644 index 0000000..86a9a44 --- /dev/null +++ b/admin/2022-08-16/run.py @@ -0,0 +1,722 @@ +import os +import time +from tkinter import messagebox +from tkinter import ttk +from tkinter import * +from tkinter.ttk import * +import time + + + +def container_list_check(): + global container_list + global front_container_list + global container_name_list + + user_name = str(os.popen("whoami").read()) + user_name = user_name.rstrip('\n') + #print(user_name) + + os.system(str("docker ps -a > ./docker_container")) + + f = open("./docker_container", "rt", encoding="utf-8") + name = f.readlines() + f.close() + os.system("rm ./docker_container") + + name = "".join(name).split("\n") + + var = 0 + var_list = [] + + for i in range(len(name)): + #print(i) + var = "".join(name[i]).split(" ") + #print(var) + var_list.append(var) + + var_list = var_list[:-1] + + #print(var_list) + + container_list = [] + front_container_list = [] + container_name_list = [] + for i in range(len(var_list)): + temp=[] + temp = ' '.join(var_list[i]).split() + #print(temp[-1]) + container_list.append(temp) + container_list = container_list[1:] + #print(container_list) + + #print(" ") + + for i in range(len(container_list)): + front_container_list.append(container_list[i][-1] + " " + container_list[i][6] + " " + container_list[i][3] + " " +container_list[i][4] + " " + container_list[i][1]) + container_name_list.append(container_list[i][-1]) + #print(front_container_list) + for i in range(len(front_container_list)): + lb1.insert(i, str(front_container_list[i])) + + +def refresh_button_action(): + lb1.delete(0,END) + container_list_check() + + +def undo_select_container(): + ent1.delete(0,len(ent1.get())) + +def select_image(): + idx = lb1.curselection() + idx = lb1.index(idx) + #print(int(idx)) + ent1.delete(0,len(ent1.get())) + #ent1.insert(0, str(lb1.get(idx))) + ent1.insert(0, str(container_name_list[idx])) + + + + + +def commit_btn_action(): + if(len(ent1.get())==0): + messagebox.showerror("Info", "Please Select Container") + + else: + commit = Toplevel(win,width=600, height=400) + commit.grab_set() + commit.title("Container Commit") + #commit.option_add("*Font", "Arial 15") + commit.resizable(False, False) + + + commit_title = Label(commit) + commit_title.config(font="Arial 18") + commit_title.config(text="Container Commit") + commit_title.place(x=20, y=10, width=560, height=30) + + commit_lab1 = Label(commit) + commit_lab1.place(x=20, y=80, width=180, height=30) + commit_lab1.config(text="container_name") + + commit_ent1 = Entry(commit) + commit_ent1.insert(0, str(ent1.get())) + commit_ent1.place(x=210, y=80, width=300, height=30) + + commit_lab2 = Label(commit) + commit_lab2.place(x=20, y=150, width=560, height=30) + commit_lab2.config(text="Insert New Image Name") + + commit_lab3 = Label(commit) + commit_lab3.place(x=20, y=210, width=180, height=30) + commit_lab3.config(text="Image Name : ") + + commit_ent3 = Entry(commit) + commit_ent3.place(x=210, y=210, width=300, height=30) + + commit_lab4 = Label(commit) + commit_lab4.place(x=20, y=270, width=180, height=30) + commit_lab4.config(text="Image Tag : ") + + commit_ent4 = Entry(commit) + commit_ent4.place(x=210, y=270, width=300, height=30) + + def commit_cancel_btn_action(): + commit.destroy() + + def commit_summit_btn_action(): + if(len(commit_ent3.get())==0 or len(commit_ent4.get())==0): + messagebox.showerror("Info", "Please Insert Name and Tag.") + else: + messagebox.showinfo("Info", "Container Commiting...") + command = "docker commit " + ent1.get() + " " + commit_ent3.get() + ":" + commit_ent4.get() + os.system(command) + time.sleep(0.5) + commit.destroy() + lb1.delete(0,END) + container_list_check() + image_list_check() + + commit_cancle_btn = Button(commit) + commit_cancle_btn.config(command=commit_cancel_btn_action) + commit_cancle_btn.config(text="Cancel") + commit_cancle_btn.place(x=360, y=320, width=100, height=60) + + commit_summit_btn = Button(commit) + commit_summit_btn.config(command=commit_summit_btn_action) + commit_summit_btn.config(text="Summit") + commit_summit_btn.place(x=480, y=320, width=100, height=60) + + + + + + + +def start_btn_action(): + if(len(ent1.get())==0): + messagebox.showerror("Info", "Please Select Container") + else: + messagebox.showinfo("Info", "Container will be Start") + command = "docker start " + ent1.get() + os.system(command) + time.sleep(0.5) + lb1.delete(0,END) + container_list_check() + + + +def stop_btn_action(): + if(len(ent1.get())==0): + messagebox.showerror("Info", "Please Select Container") + else: + messagebox.showinfo("Info", "Container will be Stop") + command = "docker stop " + ent1.get() + os.system(command) + time.sleep(0.5) + lb1.delete(0,END) + container_list_check() + +def remove_btn_action(): + if(len(ent1.get())==0): + messagebox.showerror("Info", "Please Select Container") + else: + remove = Toplevel(win,width=400, height=200) + remove.grab_set() + remove.title("Container remove") + #commit.option_add("*Font", "Arial 15") + remove.resizable(False, False) + + remove_lab1 = Label(remove) + remove_lab1.place(x=130, y=30, width=200, height=30) + remove_lab1.config(text="Are You Sure?") + + def remove_cancel_btn_action(): + remove.destroy() + + def remove_summit_btn_action(): + messagebox.showinfo("Info", "Container will be remove") + command = "docker rm -f " + ent1.get() + os.system(command) + remove.destroy() + time.sleep(0.5) + lb1.delete(0,END) + container_list_check() + image_list_check() + + remove_cancle_btn = Button(remove) + remove_cancle_btn.config(command=remove_cancel_btn_action) + remove_cancle_btn.config(text="Cancel") + remove_cancle_btn.place(x=100, y=100, width=80, height=60) + + remove_summit_btn = Button(remove) + remove_summit_btn.config(command=remove_summit_btn_action) + remove_summit_btn.config(text="Summit") + remove_summit_btn.place(x=220, y=100, width=80, height=60) + + + + + + + + + + + + + + + + + + + + +########################################################## +# tab2 + +def image_list_check(): + + global front_image_list + + os.system(str("docker images > ./docker_images")) + + f = open("./docker_images", "rt", encoding="utf-8") + name = f.readlines() + f.close() + os.system("rm ./docker_images") + + name = "".join(name).split("\n") + + var = 0 + var_list = [] + + for i in range(len(name)): + #print(i) + var = "".join(name[i]).split(" ") + #print(var) + var_list.append(var) + + var_list = var_list[:-1] + + #print(var_list) + + image_list = [] + front_image_list = [] + image_name_list = [] + for i in range(len(var_list)): + temp=[] + temp = ' '.join(var_list[i]).split() + #print(temp[-1]) + image_list.append(temp) + image_list = image_list[1:] + #print(image_list) + + for i in range(len(image_list)): + front_image_list.append(image_list[i][0] + ":" + image_list[i][1]) + #print(front_image_list) + + for i in range(len(front_image_list)): + t2_lb1.insert(i, front_image_list[i]) + + +def t2_refresh_button_action(): + t2_lb1.delete(0,END) + image_list_check() + + +def t2_undo_select_container(): + t2_ent1.delete(0,len(t2_ent1.get())) + +def t2_select_image(): + idx = t2_lb1.curselection() + idx = t2_lb1.index(idx) + #print(int(idx)) + t2_ent1.delete(0,len(t2_ent1.get())) + t2_ent1.insert(0, str(front_image_list[idx])) + + + +def t2_rmi_btn_action(): + if(len(t2_ent1.get())==0): + messagebox.showerror("Info", "Please Select image") + else: + remove = Toplevel(win,width=400, height=200) + remove.grab_set() + remove.title("image remove") + #commit.option_add("*Font", "Arial 15") + remove.resizable(False, False) + + remove_lab1 = Label(remove) + remove_lab1.place(x=130, y=30, width=200, height=30) + remove_lab1.config(text="Are You Sure?") + + def remove_cancel_btn_action(): + remove.destroy() + + def remove_summit_btn_action(): + messagebox.showinfo("Info", "Image will be remove") + command = "docker rmi -f " + t2_ent1.get() + os.system(command) + remove.destroy() + time.sleep(0.5) + t2_lb1.delete(0,END) + image_list_check() + + remove_cancle_btn = Button(remove) + remove_cancle_btn.config(command=remove_cancel_btn_action) + remove_cancle_btn.config(text="Cancel") + remove_cancle_btn.place(x=100, y=100, width=80, height=60) + + remove_summit_btn = Button(remove) + remove_summit_btn.config(command=remove_summit_btn_action) + remove_summit_btn.config(text="Summit") + remove_summit_btn.place(x=220, y=100, width=80, height=60) + + + +def t2_tag_btn_action(): + if(len(t2_ent1.get())==0): + messagebox.showerror("Info", "Please Select image") + + else: + t2_tag = Toplevel(win,width=600, height=400) + t2_tag.grab_set() + t2_tag.title("Image Tag") + #commit.option_add("*Font", "Arial 15") + t2_tag.resizable(False, False) + + + t2_tag_title = Label(t2_tag) + t2_tag_title.config(font="Arial 18") + t2_tag_title.config(text="Image Tag") + t2_tag_title.place(x=20, y=10, width=560, height=30) + + t2_tag_lab1 = Label(t2_tag) + t2_tag_lab1.place(x=20, y=80, width=180, height=30) + t2_tag_lab1.config(text="Image_name") + + t2_tag_ent1 = Entry(t2_tag) + t2_tag_ent1.insert(0, str(t2_ent1.get())) + t2_tag_ent1.place(x=210, y=80, width=300, height=30) + + t2_tag_lab2 = Label(t2_tag) + t2_tag_lab2.place(x=20, y=150, width=560, height=30) + t2_tag_lab2.config(text="Insert New Image Name") + + t2_tag_lab3 = Label(t2_tag) + t2_tag_lab3.place(x=20, y=210, width=180, height=30) + t2_tag_lab3.config(text="Image Name : ") + + t2_tag_ent3 = Entry(t2_tag) + t2_tag_ent3.place(x=210, y=210, width=300, height=30) + + t2_tag_lab4 = Label(t2_tag) + t2_tag_lab4.place(x=20, y=270, width=180, height=30) + t2_tag_lab4.config(text="Image Tag : ") + + t2_tag_ent4 = Entry(t2_tag) + t2_tag_ent4.place(x=210, y=270, width=300, height=30) + + def t2_tag_cancel_btn_action(): + t2_tag.destroy() + + def t2_tag_summit_btn_action(): + if(len(t2_tag_ent3.get())==0 or len(t2_tag_ent4.get())==0): + messagebox.showerror("Info", "Please Insert Name and Tag.") + else: + messagebox.showinfo("Info", "Image Tagging will be done.") + command = "docker tag " + t2_ent1.get() + " " + t2_tag_ent3.get() + ":" + t2_tag_ent4.get() + os.system(command) + time.sleep(0.5) + t2_tag.destroy() + t2_lb1.delete(0,END) + image_list_check() + + t2_commit_cancle_btn = Button(t2_tag) + t2_commit_cancle_btn.config(command=t2_tag_cancel_btn_action) + t2_commit_cancle_btn.config(text="Cancel") + t2_commit_cancle_btn.place(x=360, y=320, width=100, height=60) + + t2_commit_summit_btn = Button(t2_tag) + t2_commit_summit_btn.config(command=t2_tag_summit_btn_action) + t2_commit_summit_btn.config(text="Summit") + t2_commit_summit_btn.place(x=480, y=320, width=100, height=60) + + + + +def t2_pull_btn_action(): + t2_pull = Toplevel(win,width=600, height=250) + t2_pull.grab_set() + t2_pull.title("Image Pull") + #t2_pull.option_add("*Font", "Arial 15") + t2_pull.resizable(False, False) + + t2_pull_title = Label(t2_pull) + t2_pull_title.config(font="Arial 18") + t2_pull_title.config(text="Image Pull") + t2_pull_title.place(x=20, y=10, width=560, height=30) + + t2_pull_lab1 = Label(t2_pull) + t2_pull_lab1.place(x=20, y=60, width=230, height=30) + t2_pull_lab1.config(font="Arial 12") + t2_pull_lab1.config(text="Insert Pull Image name : ") + + t2_pull_ent1 = Entry(t2_pull) + #t2_pull_ent1.insert(0, str(t2_ent1.get())) + t2_pull_ent1.place(x=210, y=60, width=360, height=30) + + t2_pull_lab2 = Label(t2_pull) + t2_pull_lab2.place(x=20, y=110, width=230, height=30) + t2_pull_lab2.config(font="Arial 12") + t2_pull_lab2.config(text="Insert Pull Image tag : ") + + t2_pull_ent2 = Entry(t2_pull) + #t2_pull_ent1.insert(0, str(t2_ent1.get())) + t2_pull_ent2.place(x=210, y=110, width=360, height=30) + + def t2_pull_cancel_btn_action(): + t2_pull.destroy() + + def t2_pull_summit_btn_action(): + if(len(t2_pull_ent1.get())==0): + messagebox.showerror("Info", "Please Insert Image:Tag.") + else: + messagebox.showinfo("Info", "Image Pull will be start. \n Please Check Console.") + command = "docker pull " + t2_pull_ent1.get() + ":" + t2_pull_ent2.get() + os.system(command) + time.sleep(0.5) + t2_pull.destroy() + t2_lb1.delete(0,END) + image_list_check() + + + t2_commit_cancle_btn = Button(t2_pull) + t2_commit_cancle_btn.config(command=t2_pull_cancel_btn_action) + t2_commit_cancle_btn.config(text="Cancel") + t2_commit_cancle_btn.place(x=350, y=170, width=100, height=60) + + t2_commit_summit_btn = Button(t2_pull) + t2_commit_summit_btn.config(command=t2_pull_summit_btn_action) + t2_commit_summit_btn.config(text="Summit") + t2_commit_summit_btn.place(x=475, y=170, width=100, height=60) + + + + + +def t2_push_btn_action(): + if(len(t2_ent1.get())==0): + messagebox.showerror("Info", "Please Select image") + + else: + messagebox.showinfo("Info", "Image Push Will be Start. \n Please Check Console.") + command = "docker push " + t2_ent1.get() + os.system(command) + + + + + + + + + + + + + + + + + + + + +# ------------------------------------------------------ +# gui main +win = Tk() +win.title("MW Docker") +win.option_add("*Font", "Arial 15") +win.resizable(False, False) + +notebook=Notebook(win, width=900, height=600) +notebook.pack() + +tab1=Frame(win) +notebook.add(tab1, text=" Containers ") +tab2=Frame(win) +notebook.add(tab2, text=" Images ") + + + +# 로고 +lab_img = Label(win) +current_path = str(os.popen("pwd").read()) +current_path = current_path.rstrip('\n') +image_path = current_path + "/image/miruware_logo.png" +img = PhotoImage(file = image_path, master=win) +img = img.subsample(3) +lab_img.config(image=img) +lab_img.place(x=700, y=40) + + + + + + + + + + + + + + + + + + +################################################# +# tab 1 +# 라벨 +lab1 = Label(tab1) +lab1.place(x=20, y=10, width=490, height=30) +lab1.config(text="Container List") + +# 리스트 박스 설명 +lab2 = Label(tab1) +lab2.place(x=20, y=45, width=490, height=30) +lab2.config(font="Arial 10") +lab2.config(text="Name Status uptime base image") + + +# 리스트박스 +lb1 = Listbox(tab1) +container_list_check() +lb1.config(font="Arial 12") +lb1.place(x=20, y=70, width=590, height=410) + +xscrollbar = Scrollbar(tab1, orient="horizontal") +xscrollbar.config(command=lb1.xview) +xscrollbar.place(x=20, y=480, width=590, height=20) + +yscrollbar = Scrollbar(tab1, orient="vertical") +yscrollbar.config(command=lb1.yview) +yscrollbar.place(x=610, y=70, width=20, height=410) + +# 새로고침 버튼 +refresh_button = Button(tab1, text="Reload") +refresh_button.config(command=refresh_button_action) +refresh_button.place(x=470, y=40, width=140, height=25) + +# Button +up_btn = Button(tab1, text="Undo") +up_btn.config(command=undo_select_container) +up_btn.place(x=130, y=510, width=160, height=30) + +select_btn = Button(tab1, text="Select") +select_btn.config(command=select_image) +select_btn.place(x=330, y=510, width=160, height=30) + +# 선택된 컨테이너 라벨 +lab3 = Label(tab1) +lab3.place(x=20, y=550, width=280, height=30) +lab3.config(text="Selected Container Name : ") + +# 선택된 이미지 이름 +ent1 = Entry(tab1) +ent1.place(x=290, y=550, width=320, height=30) + +#------------------------------------ +# 우측 버튼 + +commit_btn = Button(tab1, text="Commit") +commit_btn.config(command=commit_btn_action) +commit_btn.place(x=650, y=130, width=200, height=60) + + + +start_btn = Button(tab1, text="Start") +start_btn.config(command=start_btn_action) +start_btn.place(x=650, y=240, width=200, height=60) + +stop_btn = Button(tab1, text="Stop") +stop_btn.config(command=stop_btn_action) +stop_btn.place(x=650, y=350, width=200, height=60) + +remove_btn = Button(tab1, text="remove") +remove_btn.config(command=remove_btn_action) +remove_btn.place(x=650, y=460, width=200, height=60) + + + + + + + + + + + + + + + + + + +########################################################## +# image tab +# tab 2 +# 라벨 +t2_lab1 = Label(tab2) +t2_lab1.place(x=20, y=10, width=490, height=30) +t2_lab1.config(text="Imagea List") + +# 리스트 박스 설명 +t2_lab2 = Label(tab2) +t2_lab2.place(x=20, y=45, width=490, height=30) +t2_lab2.config(font="Arial 10") +t2_lab2.config(text="Name : tag") + + +# 리스트박스 +t2_lb1 = Listbox(tab2) +image_list_check() +t2_lb1.config(font="Arial 13") +t2_lb1.place(x=20, y=70, width=590, height=410) + +t2_xscrollbar = Scrollbar(tab2, orient="horizontal") +t2_xscrollbar.config(command=lb1.xview) +t2_xscrollbar.place(x=20, y=480, width=590, height=20) + +t2_yscrollbar = Scrollbar(tab2, orient="vertical") +t2_yscrollbar.config(command=lb1.yview) +t2_yscrollbar.place(x=610, y=70, width=20, height=410) + +# 새로고침 버튼 +t2_refresh_button = Button(tab2, text="Reload") +t2_refresh_button.config(command=t2_refresh_button_action) +t2_refresh_button.place(x=470, y=40, width=140, height=25) + +# Button +t2_up_btn = Button(tab2, text="Undo") +t2_up_btn.config(command=t2_undo_select_container) +t2_up_btn.place(x=130, y=510, width=160, height=30) + +t2_select_btn = Button(tab2, text="Select") +t2_select_btn.config(command=t2_select_image) +t2_select_btn.place(x=330, y=510, width=160, height=30) + +# 선택된 컨테이너 라벨 +t2_lab3 = Label(tab2) +t2_lab3.place(x=20, y=550, width=280, height=30) +t2_lab3.config(text="Selected image : ") + +# 선택된 이미지 이름 +t2_ent1 = Entry(tab2) +t2_ent1.place(x=200, y=550, width=650, height=30) + +pull_btn = Button(tab2, text="Pull") +pull_btn.config(command=t2_pull_btn_action) +pull_btn.place(x=650, y=120, width=200, height=60) + +push_btn = Button(tab2, text="Push") +push_btn.config(command=t2_push_btn_action) +push_btn.place(x=650, y=230, width=200, height=60) + +tag_btn = Button(tab2, text="Tag") +tag_btn.config(command=t2_tag_btn_action) +tag_btn.place(x=650, y=340, width=200, height=60) + +rmi_btn = Button(tab2, text="Remove") +rmi_btn.config(command=t2_rmi_btn_action) +rmi_btn.place(x=650, y=450, width=200, height=60) + + + + + + + + + + + + +#-------------------------------------------- +# Copyright +copyright = Label( + win, + font=("Helvetica", 9)) +copyright.config(text="Made By Suseong,Yang Email : tntjd5596@miruware.com 2022.08.16") +copyright.place(x=420, y=605, width=500, height=30) + + + +win.mainloop() \ No newline at end of file diff --git a/admin/image/miruware-logo.jpg b/admin/image/miruware-logo.jpg new file mode 100644 index 0000000..2db2bb8 Binary files /dev/null and b/admin/image/miruware-logo.jpg differ diff --git a/admin/image/miruware_logo.ico b/admin/image/miruware_logo.ico new file mode 100644 index 0000000..4d928f4 Binary files /dev/null and b/admin/image/miruware_logo.ico differ diff --git a/admin/image/miruware_logo.png b/admin/image/miruware_logo.png new file mode 100644 index 0000000..c924da4 Binary files /dev/null and b/admin/image/miruware_logo.png differ diff --git a/admin/run.py b/admin/run.py index c95219d..86a9a44 100644 --- a/admin/run.py +++ b/admin/run.py @@ -476,6 +476,7 @@ def t2_push_btn_action(): else: messagebox.showinfo("Info", "Image Push Will be Start. \n Please Check Console.") command = "docker push " + t2_ent1.get() + os.system(command) @@ -515,7 +516,10 @@ def t2_push_btn_action(): # 로고 lab_img = Label(win) -img = PhotoImage(file = "/home/miruware/yss/test/miruware_logo.png", master=win) +current_path = str(os.popen("pwd").read()) +current_path = current_path.rstrip('\n') +image_path = current_path + "/image/miruware_logo.png" +img = PhotoImage(file = image_path, master=win) img = img.subsample(3) lab_img.config(image=img) lab_img.place(x=700, y=40) @@ -710,8 +714,8 @@ def t2_push_btn_action(): copyright = Label( win, font=("Helvetica", 9)) -copyright.config(text="Made By Suseong,Yang Email : tntjd5596@miruware.com 2021.07.06") -copyright.place(x=470, y=605, width=500, height=30) +copyright.config(text="Made By Suseong,Yang Email : tntjd5596@miruware.com 2022.08.16") +copyright.place(x=420, y=605, width=500, height=30)