Skip to content

Commit 35bb8a9

Browse files
committed
init, docker-redo v1
0 parents  commit 35bb8a9

File tree

4 files changed

+123
-0
lines changed

4 files changed

+123
-0
lines changed

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2018 Zachary Spofford
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Utilties
2+
3+
A collection of random scripts
4+
5+
## Authors
6+
7+
* **Zachary Spofford** - *Initial work* - [Spoofardio](https://github.com/Spoofardio)
8+
9+
See also the list of [contributors](https://github.com/spoofardio/recommendation-service/contributors) who participated in this project.
10+
11+
## License
12+
13+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

docker-redo/README.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Docker Redo
2+
3+
Small script to recreate a docker container
4+
5+
## How to use it
6+
7+
### Get Help
8+
```
9+
source docker-redo.sh -h
10+
```
11+
### General Form
12+
```
13+
source docker-redo.sh -n <NAME> -r "<ARGS>" -i <IMAGE>
14+
```
15+
Required Arguments:
16+
```
17+
IMAGE: the docker image. this is required and there is no default value.
18+
```
19+
Optional Arguments:
20+
```
21+
Name: the name of the container. default value is `redoContainer`
22+
ARGS: the docker run arguments. default value is `-d`
23+
```
24+
25+
### Example
26+
```
27+
source docker-redo.sh -n rabbitmq -i rabbitmq:3.7 -r "-d --hostname rabbitmq -p 5672:5672 -p 15672:15672 -v rabbitmq-home:/var/lib/rabbitmq -v rabbitmq-config:/etc/rabbitmq/rabbitmq.config --restart unless-stopped"
28+
```
29+
30+
## Different Modes
31+
32+
currently there is only one mode which is the default.
33+
```
34+
stop the container
35+
remove the container
36+
delete the image
37+
repull the image
38+
recreate the container
39+
```
40+
41+
## Authors
42+
43+
* **Zachary Spofford** - *Initial work* - [Spoofardio](https://github.com/Spoofardio)
44+
45+
See also the list of [contributors](https://github.com/spoofardio/recommendation-service/contributors) who participated in this project.
46+
47+
## License
48+
49+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

docker-redo/docker-redo.sh

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
usage="use like this: \$source docker-redo.sh -n NAME -r \"ARG ARG\" -i IMAGE"
3+
arg_error="ERROR: invalid arguments. for help run \$source docker-redo.sh -h"
4+
image_error="ERROR: you must specify an image"
5+
6+
name="redoContainer"
7+
runArgs="-d"
8+
image=""
9+
10+
while [ "$1" != "" ]; do
11+
case $1 in
12+
-r | --runargs ) shift
13+
runArgs=$1
14+
;;
15+
-n | --name ) shift
16+
name=$1
17+
;;
18+
-i | --image) shift
19+
image=$1
20+
;;
21+
-h | --help ) echo "$usage"
22+
return
23+
;;
24+
* ) echo "$arg_error"
25+
return
26+
esac
27+
shift
28+
done
29+
30+
if ["$image" == ""]
31+
then
32+
echo "$image_error"
33+
return
34+
fi
35+
36+
docker stop $name
37+
docker rm $name
38+
docker rmi $image
39+
docker pull $image
40+
docker run $runArgs --name $name $image

0 commit comments

Comments
 (0)