From 73d7ae3588b8b0645f636cb99e6468cd2705dca9 Mon Sep 17 00:00:00 2001 From: tan <447542994@qq.com> Date: Thu, 3 Jan 2019 17:02:09 +0800 Subject: [PATCH 1/5] add docker-compose file --- docker-compose.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..195c8d2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: "3" + +services: + 12306ticket: + # image: + build: . + # ports: + volumes: + - ./:/usr/src/app + container_name: 12306ticket + + From 7518d21c60ec6c9af19ed4672f38817c7184aca0 Mon Sep 17 00:00:00 2001 From: tan <447542994@qq.com> Date: Mon, 7 Jan 2019 15:21:42 +0800 Subject: [PATCH 2/5] update docker files --- Dockerfile | 2 +- docker-compose.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 17fd237..555a1eb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,5 +9,5 @@ RUN pip install --no-cache-dir -r requirements.txt #EXPOSE 5010 -WORKDIR /usr/src/app/ +#WORKDIR /usr/src/app/ CMD [ "python", "run.py" ] diff --git a/docker-compose.yml b/docker-compose.yml index 195c8d2..f7b01ee 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ version: "3" services: - 12306ticket: + ticket: # image: build: . # ports: From 8c548f13de7c880de066e4ecfff8e9b1dec6d911 Mon Sep 17 00:00:00 2001 From: tan <447542994@qq.com> Date: Mon, 7 Jan 2019 16:44:12 +0800 Subject: [PATCH 3/5] modify some config about compose file. --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index f7b01ee..f1e678c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: "3" services: ticket: - # image: + image: 12306_ticket build: . # ports: volumes: From 8c2686273232f30a6206644c2a8a531ff48cb211 Mon Sep 17 00:00:00 2001 From: tan <447542994@qq.com> Date: Mon, 7 Jan 2019 16:44:36 +0800 Subject: [PATCH 4/5] add docker.sh file to control compose file --- docker.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 docker.sh diff --git a/docker.sh b/docker.sh new file mode 100755 index 0000000..c65e895 --- /dev/null +++ b/docker.sh @@ -0,0 +1,32 @@ +#!/bin/bash +#author: tan +#date: 2019-01-07 +# a script to control docker's container create restart reload and rm function + +function checkSudo (){ + if [ $UID -ne 0 ];then + echo -e 'it must be root!' + echo -e 'usage ./docker.sh {run|restart|rm}' + exit 1 + fi +} + +checkSudo + +if [ $# -eq 1 ];then + + case $1 in + "run") + echo "run";; + + "restart") + echo "restart";; + + "rm") + echo "rm";; + + *) + echo -e 'usage ./docker.sh {run|restart|rm}';; + esac + +fi From fe1ea37a7eb5646e54a77cdee711abf0b5da4da7 Mon Sep 17 00:00:00 2001 From: tan <447542994@qq.com> Date: Mon, 7 Jan 2019 17:02:35 +0800 Subject: [PATCH 5/5] complete docker script --- docker.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/docker.sh b/docker.sh index c65e895..dbeb49e 100755 --- a/docker.sh +++ b/docker.sh @@ -17,14 +17,17 @@ if [ $# -eq 1 ];then case $1 in "run") - echo "run";; + docker-compose up;; "restart") - echo "restart";; + docker-compose up --no-recreate;; "rm") - echo "rm";; - + docker-compose rm -f;; + + "drun") + docker-compose up -d;; + *) echo -e 'usage ./docker.sh {run|restart|rm}';; esac