├── README.md ├── README_KR.md ├── dcs ├── sample01.png └── snap └── snapcraft.yaml /README.md: -------------------------------------------------------------------------------- 1 | 2 | # Here is an execution file http://bit.ly/ralf_dcs 3 | * Download & Install 4 | ``` 5 | curl -sL bit.ly/ralf_dcs -o ./dcs 6 | sudo chmod 755 ./dcs 7 | sudo mv ./dcs /usr/local/bin/ 8 | ``` 9 | 10 | # docker_cli_dashboard 11 | CLi mode dashboard for Docker(in redhat, ubuntu, OSX) 12 | 13 | [![asciicast](https://asciinema.org/a/166084.png)](https://asciinema.org/a/166084) 14 | 15 | * It can be helps for type quickly :) 16 | * You just shuld send a command "dcs" for start,stop,remove, pull run... 17 | * That's all :) 18 | 19 | #### 2015/08/06 - update 20 | * You can build & verify the docker image now via dcs command ! 21 | 22 | 1. If you type "build" in dcs, you should input the parents directory name of dockerfile existing directory 23 | 2. And then the docker_build_auto.sh command shuld be downloaded automatically to be excution. 24 | 3. Through the docker_build_auto.sh, you can modify the Dockerfile for build 25 | 4. After build the image, you can verify the image good or not 26 | 6. When you finish the Verification, You can make a tag to image and upload to registry 27 | 6. After the upload to registry, you can clean the temporary image and log file 28 | 29 | 30 | #### 2016/01/13- update 31 | * You can feel free type the command as you want 32 | * For example, if you need to remove several images, you can type as below 33 | ``` 34 | rm 123124 0981723 09871023 0983 35 | ``` 36 | * New function has been applied for exception process of sudo command use or not 37 | 38 | #### 2016/07/04- update 39 | * Purge function has been applied for no use image 40 | ``` 41 | purge 42 | ``` 43 | 44 | #### 2016/07/13- update 45 | 46 | 1. Clean function has been applied for no use Volumes 47 | ``` 48 | clean 49 | ``` 50 | 2. In-line command input support 51 | * You can use an in-line command as below 52 | ``` 53 | $ dcs clean 54 | ``` 55 | 56 | 57 | #### 2016/10/24- update 58 | 59 | 1. Supports entering the running docker using the `it` command 60 | ``` 61 | it 62 | 63 | or 64 | 65 | it [image id] 66 | ``` 67 | 68 | #### 2016/11/24- update 69 | 70 | 1. Bug Patch for `it` command of "Active process"(bug was `it` command found a in-active process) 71 | 2. "run" command 사용시 Port-expose를 추가 할 수 있는 step을 추가 72 | 2. Port expose step supports when you need to run the container 73 | ``` 74 | ====================================== 75 | run 76 | == Please insert a image number [1 - 23 ] 77 | 1 78 | == Please insert a new name for Run : 79 | test_dcss 80 | == Do you need to make port forwarding ? [host-port:container-port or null] 81 | 8080:80 8081:81 82 | 83 | 84 | ========================================================================================================================================================= 85 | [:: Active Processors ::] 86 | ========================================================================================================================================================= 87 | | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 88 | 1 | b2d5490a70af ab7284315dff "docker-entrypoint.sh" 7 seconds ago Up 7 seconds 8983/tcp, 0.0.0.0:8080->80/tcp, 0.0.0.0:8081->81/tcp test_dcs 89 | ``` 90 | 91 | 92 | #### 2016/11/24_02- update 93 | 1. Use the "upgrade" command to automatically update the Docker Cli-dashboard! 94 | 95 | #### 2017/06/28- update 96 | 1. update for numbering for align: 1, 2, 3 -> 01, 02, 03 97 | 98 | #### 2017/07/6- update 99 | 1. update for no-use image clean via `reduce` option 100 | 101 | #### 2017/07/6- update 102 | 1. update for `prune` command all clean(volume/network/process/image) 103 | 104 | #### 2017/10/23- update 105 | 1. Function update: `save` for All docker image dump to the local file 106 | 2. Function update: `load` for the local docker image file to the Docker images list 107 | 108 | #### 2017/11/09- update 109 | 1. Function update: `log` for docker process log show 110 | 2. Function name change: halt -> aps(all process stop) 111 | 112 | #### 2018/08/09- update 113 | 1. Function update: `stat` for All or selected container status monitoring 114 | 2. Function update: `run` just run container without going into container 115 | 3. Function update: Remove `attach` from `sa` and rename `sa` to `start` 116 | 4. Change code to match the bash syntax 117 | 5. Add command prompt 118 | 119 | #### 2018/08/21- update 120 | 1. Function update: Add volume mount option to `run` 121 | 2. Change some code to match the bash syntax 122 | 123 | #### 2020/03/02- update 124 | 1. Podman command supports 125 | 126 | #### 2020/12/30- update 127 | 1. Update for new bit.ly url for master branch's command directly 128 | 2. Enable in-line command for `$ dcs prune` 129 | -------------------------------------------------------------------------------- /README_KR.md: -------------------------------------------------------------------------------- 1 | # Here is an execution file http://bit.ly/dcs_ 2 | 3 | # Download & Install 4 | ``` 5 | curl -sL bit.ly/dcs_0 -o ./dcs 6 | sudo chmod 755 ./dcs 7 | sudo mv ./dcs /usr/bin/dcs 8 | ``` 9 | 10 | # docker_cli_dashboard 11 | CLi mode dashboard for Docker(in redhat, ubuntu, OSX) 12 | 13 | [![asciicast](https://asciinema.org/a/166084.png)](https://asciinema.org/a/166084) 14 | 15 | * It can be helps for type quickly :) 16 | * You just shuld send a command "dcs" for start,stop,remove, pull run... 17 | * That's all :) 18 | 19 | 2015/08/06 - update 20 | * Docker Cli Dashboard를 통해서 자동으로 이미지 build 및 Verification 할 수 있는 command를 추가 하였습니다. :) 21 | 22 | 1. "build" command 입력 시, Build에 사용 될 Dockerfile이 위치한 상위 디렉토리를 입력 받습니다. 23 | 2. docker_build_auto.sh command를 해당 경로에 download 받고 해당 명령을 실행 합니다. 24 | 3. 해당 경로에 속한 Dockerfile을 수정 후 build를 진행 합니다. 25 | 4. 빌드가 완료 후 image에 설정한 부분들이 정상으로 적용되었는지 verification 처리 합니다. 26 | 5. Verification 완료후 미리 지정한 tag(or user ID)가 할당되며, 지정된 registry로 해당 이미지의 upload를 진행합니다. 27 | 6. Upload가 완료된 후 작업을 위해 사용된 temp 이미지 멫 log file을 clean-up 합니다 28 | 29 | * Image verification을 위한 명령어를 CheckCommand= 변수에 지정 해 주시면 이미지가 생성 된 후 확인을 진행 합니다. 30 | 31 | 2016/01/13- update 32 | * 명령어 입력 부분에 command를 자유롭게 입력 할 수 있습니다. 33 | * 복수개의 이미지를 삭제 하고자 할 경우 아래와 같이 입력 가능합니다. 34 | 35 | 2016/04/20- update 36 | * OS별 Sudo 사용 유무에 따른 예외처리 적용하였습니다. 37 | ``` 38 | rm 123124 0981723 09871023 0983 39 | ``` 40 | 41 | 2016/07/04- update 42 | * 사용하지 않는 Docker Processors 정리 기능 43 | ``` 44 | purge 45 | ``` 46 | 47 | 2016/07/13- update 48 | 49 | 1. 사용하지 않는 Volume 삭제기능 추가 50 | 2. In-line command 입력방식 지원 51 | 52 | * dcs 내부에서 clean 또는, dcs clean 형태로 사용하지 않는 Volume 정리 53 | ``` 54 | clean 55 | ``` 56 | 57 | 2016/10/24- update 58 | 59 | 1. "it" command 를 사용으로 running중인 docker 내부로 들어가기 지원 60 | ``` 61 | it 62 | ``` 63 | 64 | 2016/11/24- update 65 | 66 | 1. "it" command 를 사용시 활성화된 Processor로 들어가기로 수정(기존에는 비활성화된 Processor를 찾는 문제 있었음) 67 | 1. "run" command 사용시 Port-expose를 추가 할 수 있는 step을 추가 68 | ``` 69 | ====================================== 70 | run 71 | == Please insert a image number [1 - 23 ] 72 | 1 73 | == Please insert a new name for Run : 74 | test_dcss 75 | == Do you need to make port forwarding ? [host-port:container-port or null] 76 | 8080:80 8081:81 77 | 78 | 79 | ========================================================================================================================================================= 80 | [:: Active Processors ::] 81 | ========================================================================================================================================================= 82 | | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 83 | 1 | b2d5490a70af ab7284315dff "docker-entrypoint.sh" 7 seconds ago Up 7 seconds 8983/tcp, 0.0.0.0:8080->80/tcp, 0.0.0.0:8081->81/tcp test_dcs 84 | ``` 85 | 86 | 87 | #### 2016/11/24_02- update 88 | 89 | 1. "upgrade" command를 사용하여 Docker Cli-dashboard를 자동 update 할 수 있습니다! 90 | 91 | 92 | #### 2017/07/6- update 93 | 1. 사용하지 않는 이미지 정리 - reduce 옵션 추가 94 | 95 | 96 | #### 2017/07/6- update 97 | 1. `prune` 옵션을 사용한 docker 정리하기 기능 추가(volume/network/process/image) 98 | 99 | 100 | #### 2017/10/23- update 101 | 1. `save` 기능을 사용하여 docker 내부의 모든 이미들을 로컬파일로 저장하기 기능 추가 102 | 1. `load` 기능을 사용하여 로컬에 저장된 이미지 파일을 Docker에 등록하는 기능 추가 103 | 104 | 105 | #### 2017/11/09- update 106 | 1. `log` 기능을 사용하여 docker process의 log를 확인 하는 기능 추가 107 | 2. 명령어 이름 변경: halt -> aps (all process stop) 108 | 109 | #### 2018/08/09- update 110 | 1. `stat` 기능을 사용하여 컨테이너 상태를 모니터링 하는 기능 추가 111 | 2. `run` 사용시 컨테이너 내부로 들어가지 않고 실행하도록 변경 112 | 3. `sa` 기능에서 `attach`를 빼고 명령어를 `start` 로 변경 113 | 4. 코드 전체를 bash 문법에 맞게 변경 114 | 5. 커맨드 프롬프트 추가 115 | 116 | #### 2018/08/21- update 117 | 1. `run` 사용시 volume mount 옵션 기능 추가 118 | 2. bash 문법에 맞게 몇몇 커맨드 수정 119 | 120 | #### 2020/03/02- update 121 | 1. Podman 명령어를 우선 지원합니다. 122 | -------------------------------------------------------------------------------- /dcs: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | ### docker container control box V. 2.8 3 | ### Code from https://github.com/ralfyang/docker_cli_dashboard. Powered by Github. 4 | ### Made by ralf goody80762@gmail.com 5 | ### Rewritten by tescom tescom@atdt01410.com 2018.08.08 6 | 7 | ## Make sure build DIR 8 | BUildDirConf="${HOME}/build_dir.conf" 9 | if [ ! -f ${BUildDirConf} ];then 10 | touch ${BUildDirConf} 11 | fi 12 | extra_input=$1 13 | BuildDir=$(cat ${BUildDirConf}) 14 | exefile=$(command -v dcs) 15 | 16 | 17 | ## Please modify under variable for the private repository if you have. 18 | #Docker_repo=$(cat /data/z/etc/init.d/docker | grep "^connection" | awk -F '=' '{print $2}' | sed -e 's/"//g' ) 19 | #Docker_repo="[Docker repository IP]:[port]" 20 | Docker_repo="" 21 | Shell_cmd="/bin/bash" 22 | 23 | HOST=$(hostname) 24 | DATE=$(date +%Y%m%d) 25 | 26 | ## find a command 27 | if [[ $(command -v podman) == "" ]];then 28 | Docker_comm=$(command -v docker) 29 | else 30 | Docker_comm=$(command -v podman) 31 | 32 | fi 33 | ## OS Check 34 | Docker_version=$($Docker_comm -v | awk -F',' '{print $1}') 35 | ## Check the sudo 36 | if [[ $(whoami) = "root" ]];then 37 | SUDO="" 38 | else 39 | SUDO="sudo" 40 | fi 41 | 42 | Comm="${SUDO} ${Docker_comm}" 43 | 44 | #ChkOS=$(cat /etc/*-release 2> /dev/null | head -1) 45 | if [[ $(uname) == Linux ]];then 46 | osv="linux" 47 | elif [[ $(uname) == Darwin ]];then 48 | Comm="${Docker_comm}" 49 | osv="osx" 50 | fi 51 | 52 | 53 | ## Temporary file create for work memory 54 | Tmp_imgfile="${HOME}/docker_imgtmp.txt" 55 | Tmp_psfile="${HOME}/docker_pstmp.txt" 56 | Tmp_psAfile="${HOME}/docker_psAtmp.txt" 57 | Tmp_tag="${HOME}/docker_tag.txt" 58 | 59 | exit_abnormal() { 60 | stty echo 61 | rm -f ${Tmp_imgfile} ${Tmp_psfile} ${Tmp_psAfile} ${Tmp_tag} 2> /dev/null 62 | exit 1 63 | } 64 | 65 | 66 | ### Break sign catch for line break fix 67 | trap exit_abnormal SIGINT SIGTERM 68 | 69 | 70 | 71 | 72 | BAR="=========================================================================================================================================================" 73 | { 74 | echo ${BAR} 75 | echo " [:: Docker Images ::]" 76 | echo ${BAR} 77 | ${Comm} images |awk '{printf "%.2d | "$0"\n",NR-1}' | sed -e 's/^00/ /g' 78 | } >| ${Tmp_imgfile} 79 | 80 | { 81 | echo "" 82 | echo "" 83 | echo ${BAR} 84 | echo " [:: Active Processors ::]" 85 | echo ${BAR} 86 | ${Comm} ps |awk '{printf "%.2d | "$0"\n",NR-1}' |sed -e 's/^00/ /g' 87 | } >| ${Tmp_psAfile} 88 | 89 | { 90 | echo "" 91 | echo "" 92 | echo ${BAR} 93 | echo " [:: All Processors ::]" 94 | echo ${BAR} 95 | ${Comm} ps -a |awk '{printf "%.2d | "$0"\n",NR-1}' |sed -e 's/^00/ /g' 96 | } >| ${Tmp_psfile} 97 | 98 | if [[ $osv = "osx" ]];then 99 | for tmpfiles in ${Tmp_imgfile} ${Tmp_imgfile} ${Tmp_psAfile} 100 | do 101 | sed -i "" 's/^0 / /g' ${tmpfiles} 102 | done 103 | else 104 | for tmpfiles in ${Tmp_imgfile} ${Tmp_imgfile} ${Tmp_psAfile} 105 | do 106 | sed -i 's/^0 / /g' ${tmpfiles} 107 | done 108 | fi 109 | 110 | 111 | Print_screen(){ 112 | ## Print screen 113 | clear -x 114 | cat ${Tmp_imgfile} ${Tmp_psAfile} ${Tmp_psfile} 115 | 116 | echo "" 117 | echo "" 118 | echo "======================================" 119 | echo " Please Insert a command as below :) " 120 | echo "= Processor ========================== = Image ============================== = Commit & Push =====================" 121 | echo " Run the container ---------- [ run ]| Pull Image ------------- [ pull ] | Commit --------------------- [commit]" 122 | echo " Start ---------- [ start]| Remove Image ------------- [ rmi ] | Login to registry ---------- [ login]" 123 | echo " Stop ---------- [ stop ]| Build Image ------------- [ build] | Tagging & Push ------------- [ push ]" 124 | echo " Send command ---------- [ exec ]| Purge volume ------------- [ clean] | Prune image/volume/network - [ prune]" 125 | echo " Into the running docker ---- [ it ]| Save All images to tarball - [ save ] | Container Stats ------------ [ stat ]" 126 | echo " Remove PS ---------- [ rm ]| Load the image from DIR ---- [ load ] | * Star here! - https://bit.ly/git_dcs" 127 | echo " Show log ---------- [ log ]| --------------------------------------| upgrade check & upgrade upgrade" 128 | echo " Purge Processor ---------- [ purge]| Cli ---------- [ Type free as below ] | Exit Ctrl+c" 129 | echo " All Processor stop!! ------- [ aps ]| ex) stop 910930 19809 102039 09103 | ${Docker_version}" 130 | echo "======================================| ===================================== | =====================================" 131 | printf "CMD>> " 132 | } 133 | 134 | if [[ ${extra_input} = "" ]];then 135 | Print_screen 136 | read -r CommandX 137 | else 138 | CommandX=${extra_input} 139 | fi 140 | 141 | 142 | ## Make a number & array 143 | ImageNum=$(tail -1 ${Tmp_imgfile} | awk '{print $1}') 144 | PsNum=$(tail -1 ${Tmp_psfile} | awk '{print $1}') 145 | PsANum=$(tail -1 ${Tmp_psAfile} | awk '{print $1}') 146 | ImageIDArray=($(cat ${Tmp_imgfile} | awk '{print $5}' | tail -n +4)) 147 | ProcessorIDArray=($(cat ${Tmp_psfile} | awk '{print $3}' | tail -n +5)) 148 | ProcessorAIDArray=($(cat ${Tmp_psAfile} | awk '{print $3}' | tail -n +5)) 149 | 150 | ## Function for command as below 151 | # 2018.08.08 change container start options 152 | # -it /bin/sh --> -id 153 | # 2018.08.21 add volume mount option 154 | run_container(){ 155 | echo " == Do you need to make port forwarding ? [host-port:container-port or null] " 156 | read -r portcheck 157 | if [[ ${portcheck} = "" ]];then 158 | port_expose="" 159 | else 160 | port_parser=$(echo "${portcheck}" | sed -e 's/ [0-9]*:[0-9]/ -p&/g') 161 | port_expose="-p ${port_parser}" 162 | fi 163 | while : ; do 164 | echo " == Do you need to make volume mount ? [host-path:container-path or null] " 165 | read -r volumemount 166 | if [[ ${volumemount} = "" ]];then 167 | volume_mount_option="" 168 | break 169 | else 170 | chk_dir=$(echo ${volumemount} | awk -F: '{print $1}') 171 | if [ -d ${chk_dir} ];then 172 | echo "" 173 | echo "Directory Check... Done" 174 | echo "" 175 | volume_mount_option="-v ${volumemount}" 176 | break 177 | else 178 | echo "" 179 | echo "${chk_dir} does not exist." 180 | echo "Please check directory path!!" 181 | echo "" 182 | fi 183 | fi 184 | done 185 | 186 | ${Comm} run ${port_expose} ${volume_mount_option} -id --name $2 ${ImageIDArray[$1]} 187 | } 188 | 189 | # 2018-08.09 change sa to start & delete attach 190 | start_container(){ 191 | ${Comm} start $1 192 | # ${Comm} attach $1 193 | } 194 | 195 | 196 | comm_container(){ 197 | ${Comm} exec ${ProcessorAIDArray[$1]} $2 198 | echo " - Please insert a any key if you have done - " 199 | read -r 200 | } 201 | 202 | build_image(){ 203 | 204 | if [[ ! -d ${BuildDir} ]];then 205 | echo "${BAR}" 206 | echo " Please insert a Directory for image build under the Dockerfile [ex) /data/git/dockerfiles_dir]" 207 | read -r ReadDir 208 | #sudo sed -i "s#^BuildDir=\"\"#BuildDir=\"${ReadDir}\"#g" ${exefile} 209 | echo "${ReadDir}" > ${BUildDirConf} 210 | cd ${ReadDir} || return 211 | else 212 | cd ${BuildDir} || return 213 | fi 214 | 215 | if [[ ! -f ./docker_build_auto.sh ]];then 216 | echo "${BAR}" 217 | echo "Do you need to install docker_build_auto.sh here ? [ y/n ]" 218 | read -r Answ 219 | if [[ ${Answ} = "y" ]] || [[ ${Answ} = "Y" ]];then 220 | wget ralfyang.github.io/docker_build_auto/docker_build_auto.sh 221 | sudo chmod 755 docker_build_auto.sh 222 | else 223 | echo "${BAR}" 224 | echo "You need to install the docker_build_auto.sh script for this work" 225 | echo "${BAR}" 226 | exit 0 227 | fi 228 | fi 229 | ./docker_build_auto.sh 230 | } 231 | 232 | rm_container(){ 233 | ${Comm} rm ${ProcessorIDArray[$1]} 234 | } 235 | 236 | it_container(){ 237 | env_chk=$(${Comm} exec -it ${ProcessorAIDArray[$1]} $Shell_cmd -c "echo \"OK\"" > /tmp/env_chk) 238 | if [[ $(grep "OK" /tmp/env_chk) != "" ]];then 239 | Shell_cmd="/bin/bash" 240 | else 241 | Shell_cmd="/bin/sh" 242 | fi 243 | rm -f /tmp/env_chk 244 | ${Comm} exec -it ${ProcessorAIDArray[$1]} $Shell_cmd -c "echo \"alias ll='ls -lai'\" >> ~/.bashrc && $Shell_cmd" 245 | } 246 | 247 | pull_image(){ 248 | ${Comm} pull $1 249 | } 250 | 251 | login_repository(){ 252 | Registry=$1 253 | if [[ ${Registry} = "" ]];then 254 | echo "Do you want to login to Private registry ? [y/N]" 255 | read -r que_registry 256 | if [[ ${que_registry} = "y" ]] || [[ ${que_registry} = "Y" ]] ;then 257 | echo " Please insert a Private registry url:" 258 | read -r Registry 259 | ${Comm} login ${Registry} 260 | else 261 | ${Comm} login 262 | fi 263 | else 264 | ${Comm} login ${Registry} 265 | fi 266 | 267 | 268 | } 269 | 270 | remove_image(){ 271 | ${Comm} rmi -f ${ImageIDArray[$1]} 272 | } 273 | 274 | ci_image(){ 275 | ${Comm} commit ${ProcessorAIDArray[$1]} $2 276 | echo "${Comm} commit ${ProcessorAIDArray[$1]} $2" 277 | } 278 | 279 | 280 | save_all_images(){ 281 | 282 | echo "Please make sure the directory for backup [default= {User_Home}]:" 283 | read -r Save_Dir 284 | if [[ ${Save_Dir} = "" ]];then 285 | Save_Dir="${HOME}" 286 | else 287 | echo " Docker image will be save in \"${Save_Dir}\" " 288 | fi 289 | 290 | docker_images=$(${Comm} images | grep -v "^REPOSITORY" | awk '{print $1":"$2}') 291 | docker_image_count=$(${Comm} images | grep -v "^REPOSITORY" | wc -l) 292 | mkdir -p ${Save_Dir}/tmp${DATE}/ 293 | 294 | echo " === Exporting the image to files === " 295 | count=1 296 | for i in ${docker_images} 297 | do 298 | echo "[ ${count} / ${docker_image_count} ] - ${i}" 299 | tar_name=$(echo "${i}" |sed -e 's/:/_/g' -e 's#/#_#g' ) 300 | ${Comm} save ${i} > ${Save_Dir}/tmp${DATE}/${tar_name}.tgz 301 | count=$(( count+1 )) 302 | done 303 | echo " === Compressing image files to Tarball file (in ${Save_Dir}/docker_images_output_${HOST}_${DATE}.tgz) === " 304 | cd ${Save_Dir}/tmp${DATE} || return 305 | tar zcvf ${Save_Dir}/docker_images_output_${HOST}_${DATE}.tgz ./*.tgz 2> /dev/null 306 | cd ${Save_Dir} || return 307 | rm -Rf ${Save_Dir}/tmp${DATE} 2> /dev/null 308 | echo " === Done === " 309 | echo " === You can use this file ${Save_Dir}/docker_images_output_${HOST}_${DATE}.tgz for Backup or magration === " 310 | sleep 1 311 | } 312 | 313 | load_all_images(){ 314 | echo " Please insert a Directory name as the file existed " 315 | read -r tarball_images_dir 316 | if [[ ${tarball_images_dir} = "" ]];then 317 | echo " Please make sure the Directory name !!" 318 | exit 319 | fi 320 | cd ${tarball_images_dir} || return 321 | ## Exception for the save file from dcs 322 | tar zxfv docker_images_output*.tgz 2> /dev/null 323 | docker_images_tgz=$(ls ${tarball_images_dir} |grep ".tgz" |grep -v "^docker_images_output*.tgz") 324 | docker_images_count=$(ls ${tarball_images_dir} |grep ".tgz" |grep -v "^docker_images_output*.tgz" |wc -l) 325 | echo " === Decompressing the file and apply the image to the Docker... === " 326 | count=1 327 | for i in ${docker_images_tgz} 328 | do 329 | echo "[ ${count} / ${docker_images_count} ] - ${i}" 330 | ${Comm} load < ${tarball_images_dir}/${i} 331 | count=$(( count+1 )) 332 | done 333 | 334 | echo " === Done === " 335 | sleep 1 336 | } 337 | 338 | Log_container(){ 339 | clear -x 340 | ${Comm} logs ${ProcessorAIDArray[$1]} 341 | echo "" 342 | echo " - Please insert an any key if you all done -" 343 | read -r 344 | } 345 | 346 | Stop_container(){ 347 | ${Comm} stop ${ProcessorAIDArray[$1]} 348 | echo "${Comm} stop ${ProcessorAIDArray[$1]}" 349 | } 350 | 351 | # 2018.08.08 Add function 352 | Container_stat(){ 353 | if [[ $1 == "all" ]];then 354 | ${Comm} stats --$1 355 | else 356 | ${Comm} stats ${ProcessorAIDArray[$1]} 357 | fi 358 | } 359 | 360 | Purge_image(){ 361 | ${Comm} rm -v $(${Comm} ps --filter status=exited -q 2>/dev/null) 2>/dev/null 362 | ${Comm} rm -v $(${Comm} ps --filter status=created -q 2>/dev/null) 2>/dev/null 363 | } 364 | 365 | All_stop_process(){ 366 | ${Comm} ps |awk '{print $1}' | grep -v 'CONTAINER' | xargs ${Comm} stop 367 | echo "--------------------- ${Comm} ps |awk '{print $1}' | grep -v 'CONTAINER' | xargs ${Comm} stop----------------------" 368 | } 369 | 370 | Purge_Old_image(){ 371 | #${Comm} rmi $(docker images --filter "dangling=true" -q --no-trunc) 2> /dev/null 372 | ${Comm} container prune --force 2>/dev/null 373 | echo " --- container clean: Done ---" 374 | echo "" 375 | ${Comm} image prune -a --force 2>/dev/null 376 | echo " --- Image clean: Done ---" 377 | echo "" 378 | ${Comm} network prune --force 2>/dev/null 379 | echo " --- Network clean: Done ---" 380 | echo "" 381 | ${Comm} volume prune --force 2>/dev/null 382 | echo " --- Volume clean: Done ---" 383 | sleep 3 384 | } 385 | 386 | Clean_volume(){ 387 | ${Comm} volume ls -qf dangling=true | xargs ${Comm} volume rm 388 | } 389 | 390 | 391 | 392 | if [[ $(echo "${CommandX}" | grep '\-y') != "" ]];then 393 | answ="y" 394 | #CommandX=$(echo "${CommandX}" | sed -e 's/ -y//g') 395 | CommandX=$("${CommandX// -y/ }") 396 | fi 397 | 398 | 399 | ## Case selection for instructions 400 | if [[ $(echo "${CommandX}" | awk '{print $2}' ) = "" ]];then 401 | case "${CommandX}" in 402 | build) 403 | build_image 404 | ;; 405 | run) 406 | echo " == Please insert a image number [01 - ${ImageNum} ]" 407 | read -r ImageNum 408 | echo " == Please insert a new name for Run :" 409 | read -r DockerName 410 | if [[ ${ImageNum} != "" ]];then 411 | run_container ${ImageNum} ${DockerName} 412 | else 413 | echo " == No Image ID == " 414 | fi 415 | 416 | ;; 417 | # 2018.08.08 change name (sa --> start) 418 | start) 419 | echo " == Please insert docker name for start :" 420 | read -r St_docker 421 | if [[ ${St_docker} != "" ]];then 422 | start_container ${St_docker} 423 | else 424 | echo " == No Processor ID == " 425 | fi 426 | ;; 427 | exec) 428 | echo " == Please insert a Active Processor number [01 - ${PsANum} ]" 429 | read -r ActiveProcessorNum 430 | echo " == Please insert a command for send to container ?" 431 | read -r CommandToContainer 432 | if [[ ${ActiveProcessorNum} != "" ]];then 433 | comm_container ${ActiveProcessorNum} ${CommandToContainer} 434 | else 435 | echo " == No Processor No. == " 436 | fi 437 | ;; 438 | it) 439 | echo " == Please insert a Processor number for into that [01 - ${PsANum} ]" 440 | read -r ProcessorNum 441 | if [[ ${ProcessorNum} != "" ]];then 442 | it_container ${ProcessorNum} 443 | else 444 | echo " == No Processor No. == " 445 | fi 446 | ;; 447 | rm) 448 | echo " == Please insert a Processor number for Remove [01 - ${PsNum} ]" 449 | read -r ProcessorNum 450 | echo " == [ ${ProcessorIDArray[${ProcessorNum}]} ]: Are you sure ? [y / n] " 451 | read -r RmAnswer 452 | if [[ ${ProcessorNum} != "" ]];then 453 | if [[ ${RmAnswer} = "y" ]];then 454 | rm_container ${ProcessorNum} 455 | fi 456 | else 457 | echo " == No Processor No. == " 458 | fi 459 | ;; 460 | pull) 461 | echo " == Please insert an image name for pulls:" 462 | read -r ImagePullname 463 | if [[ ${ImagePullname} != "" ]];then 464 | pull_image ${ImagePullname} 465 | else 466 | echo " == No image name == " 467 | fi 468 | ;; 469 | aps) 470 | if [[ ${answ} != "y" ]];then 471 | echo " == All active processor will be stop. Are sure that ? [ y/n ]:" 472 | read -r AllprocessQ 473 | if [[ ${AllprocessQ} = "y" ]];then 474 | All_stop_process 475 | fi 476 | else 477 | All_stop_process 478 | fi 479 | ;; 480 | purge) 481 | if [[ ${answ} != "y" ]];then 482 | echo " == No use processor will be remove. Are sure that ? [ y/n ]:" 483 | read -r ImagePurge 484 | if [[ ${ImagePurge} = "y" ]];then 485 | Purge_image 486 | fi 487 | else 488 | Purge_image 489 | fi 490 | ;; 491 | prune) 492 | if [[ ${answ} != "y" ]];then 493 | # echo " == No use image will be remove. Are sure that ? [ y/n ]:" 494 | # read -r ImageOldPurge 495 | # if [[ ${ImageOldPurge} = "y" ]];then 496 | Purge_Old_image 497 | # fi 498 | else 499 | Purge_Old_image 500 | fi 501 | ;; 502 | clean) 503 | if [[ ${answ} != "y" ]];then 504 | echo " == No use volume will be remove. Are sure that ? [ y/n ]:" 505 | read -r VolumeClean 506 | if [[ ${VolumeClean} = "y" ]];then 507 | Clean_volume 508 | fi 509 | else 510 | Clean_volume 511 | fi 512 | ;; 513 | 514 | save) 515 | if [[ ${answ} != "y" ]];then 516 | echo " == All images will be backup to file. OK ? [ y/n ]:" 517 | read -r SaveImg 518 | if [[ ${SaveImg} = "y" ]];then 519 | save_all_images 520 | fi 521 | else 522 | save_all_images 523 | fi 524 | ;; 525 | load) 526 | load_all_images 527 | ;; 528 | login) 529 | login_repository $1 530 | ;; 531 | 532 | rmi) 533 | echo " == Please insert a number for remove the image [01 - ${ImageNum}] " 534 | read -r RmImageNum 535 | echo " == [ ${ImageIDArray[$RmImageNum]} ]: Are you sure ? [y / n]" 536 | read -r RmIAnswer 537 | 538 | if [[ ${RmImageNum} != "" ]];then 539 | if [[ ${RmIAnswer} = "y" ]];then 540 | remove_image ${RmImageNum} 541 | fi 542 | else 543 | echo " == No image No. == " 544 | fi 545 | ;; 546 | 547 | commit) 548 | echo " == Please insert a number of Active processor [01 - ${PsANum}] " 549 | read -r CiNum 550 | echo " == Please make sure the name for use:" 551 | read -r CiAnswer 552 | if [[ ${CiNum} != "" ]];then 553 | ci_image ${CiNum} ${CiAnswer} 554 | else 555 | echo " == No image No. == " 556 | fi 557 | 558 | ;; 559 | push) 560 | if [[ ${Docker_repo} != "" ]];then 561 | ${Comm} images | grep -v "${Docker_repo}" | awk '{print NR-1,$0}' | sed -e 's/^0/ /g' > ${Tmp_tag} 562 | else 563 | ${Comm} images | awk '{print NR-1,$0}' | sed -e 's/^0/ /g' > ${Tmp_tag} 564 | fi 565 | 566 | cat ${Tmp_tag} 567 | TagNum=$(cat ${Tmp_tag} | tail -1 | awk '{print $1}') 568 | 569 | echo " == Please choose a number for tag and push [01 - ${TagNum}] " 570 | read -r TagPush 571 | echo -e "\033[32;3;7m * Please login first to the Docker registry \033[0m ex) docker login" 572 | if [[ ${TagPush} != "" ]];then 573 | echo "Taget image= $(grep \"^${TagPush} \" ${Tmp_tag} | awk '{print $2":"$3}')" 574 | TagetPush=$(grep "^${TagPush} " ${Tmp_tag} | awk '{print $2":"$3}') 575 | if [[ ${Docker_repo} = "" ]];then 576 | echo "== Do you need to make a tag ? [y / n]" 577 | read -r Tagcomm 578 | if [[ ${Tagcomm} = "y" ]];then 579 | echo "Please insert a tag name:" 580 | read -r Tagname 581 | ${Comm} tag ${TagetPush} ${Tagname} 582 | ${Comm} push ${Tagname} 583 | else 584 | ${Comm} push ${TagetPush} 585 | fi 586 | else 587 | ${Comm} tag ${TagetPush} ${Docker_repo}/${TagetPush} 588 | ${Comm} push ${Docker_repo}/${TagetPush} 589 | fi 590 | fi 591 | ;; 592 | 593 | log) 594 | echo " == Please insert a number of Active processor [01 - ${PsANum}] " 595 | read -r LogNum 596 | if [[ ${LogNum} != "" ]];then 597 | Log_container ${LogNum} 598 | else 599 | echo " == No image No. == " 600 | fi 601 | ;; 602 | stop) 603 | echo " == Please insert a number of Active processor [01 - ${PsANum}] " 604 | read -r StopNum 605 | if [[ ${StopNum} != "" ]];then 606 | Stop_container ${StopNum} 607 | else 608 | echo " == No image No. == " 609 | fi 610 | ;; 611 | 612 | upgrade) 613 | Current_ver=$(cat ${exefile} |grep 'V. [0-9].[0-9]' | sed -e 's/^### [[:alnum:]* ]* V. //g') 614 | Latest_ver=$(curl -sLH "Cache-Control: no-cache" bit.ly/ralf_dcs |grep 'V. [0-9].[0-9]' | sed -e 's/^### [[:alnum:]* ]* V. //g') 615 | if [[ ${Current_ver} < ${Latest_ver} ]];then 616 | curl -sLH "Cache-Control: no-cache" bit.ly/ralf_dcs -o /tmp/curl 617 | sudo cp /tmp/curl ${exefile} 618 | sudo rm -f /tmp/curl 619 | chmod 755 ${exefile} 620 | echo " === dcs has been updated!! - Version ${Current_ver} -> ${Latest_ver} ===" 621 | exit 0 622 | else 623 | echo " === Now you have latest version of dcs - Version ${Current_ver} ===" 624 | sleep 3 625 | fi 626 | ;; 627 | # 2018.08.08 add stat command 628 | stat) 629 | echo " == Please insert a number of Active processor [01 - ${PsANum} or enter(all)] " 630 | read -r StatNum 631 | if [[ ${StatNum} != "" ]];then 632 | Container_stat ${StatNum} 633 | else 634 | Container_stat all 635 | fi 636 | ;; 637 | 638 | esac 639 | else 640 | ${Comm} ${CommandX} 641 | fi 642 | 643 | if [[ ${extra_input} = "" ]];then 644 | ${exefile} 645 | fi 646 | -------------------------------------------------------------------------------- /sample01.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ralfyang/docker_cli_dashboard/83c32c0f58b6dde50d9ec8e247658daad608f54c/sample01.png -------------------------------------------------------------------------------- /snap/snapcraft.yaml: -------------------------------------------------------------------------------- 1 | 2 | name: docker-cli-dashboard 3 | version: '0.1' # just for humans, typically '1.2+git' or '1.3.2' 4 | summary: Single-line elevator pitch for your amazing snap # 79 char long summary 5 | description: | 6 | This is my-snap's description. You have a paragraph or two to tell the 7 | most important story about your snap. Keep it under 100 words though, 8 | we live in tweetspace and your description wants to look good in the snap 9 | store. 10 | 11 | grade: devel # must be 'stable' to release into candidate/stable channels 12 | confinement: devmode # use 'strict' once you have the right plugs and slots 13 | 14 | parts: 15 | my-part: 16 | # See 'snapcraft plugins' 17 | plugin: nil 18 | 19 | --------------------------------------------------------------------------------