mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-05-01 04:30:37 +02:00
Add docker common functions
This commit is contained in:
parent
62b0abdb6e
commit
f502deb663
2 changed files with 42 additions and 0 deletions
26
plugins/docker-common/README.md
Normal file
26
plugins/docker-common/README.md
Normal file
|
|
@ -0,0 +1,26 @@
|
||||||
|
## Docker common plugin
|
||||||
|
|
||||||
|
A set of useful docker commands.
|
||||||
|
|
||||||
|
### Dserve
|
||||||
|
```bash
|
||||||
|
cd /myStaticFolder
|
||||||
|
dserve # It will lift an nfginx and output the port used on the host
|
||||||
|
# After you used it you can stop and remove it easily by name
|
||||||
|
# all the created container names will start with the dserve prefix
|
||||||
|
docker dstop dserve-myStaticFolder
|
||||||
|
docker rm dserve-myStaticFolder
|
||||||
|
```
|
||||||
|
|
||||||
|
### Doc
|
||||||
|
This run command has many scenarios, this is just a basic configuration.
|
||||||
|
```bash
|
||||||
|
doc ls -a # It runs the command on a image with zsh inside
|
||||||
|
doc "cd .. && ls -a" # It list files from the parent folder inside the container
|
||||||
|
```
|
||||||
|
|
||||||
|
### Sdoc
|
||||||
|
Same as Doc but it mount volumes as read-only.
|
||||||
|
```bash
|
||||||
|
sdoc ls -a # It runs the command on a image with zsh inside
|
||||||
|
```
|
||||||
16
plugins/docker-common/_docker-common
Normal file
16
plugins/docker-common/_docker-common
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
dserve() {
|
||||||
|
local container=dserve${$(pwd)//\//-}
|
||||||
|
(docker restart $container \
|
||||||
|
|| docker run -d --name $container -P -v "$(pwd):/usr/share/nginx/html:ro" nginx:stable-alpine) \
|
||||||
|
&& docker port $container
|
||||||
|
}
|
||||||
|
|
||||||
|
doc() {
|
||||||
|
# TODO: add zsh conf
|
||||||
|
# bind shell so we can change current dir (cd, etc)
|
||||||
|
docker run -it --rm -v "$HOME:/root" -v "/:/all" mhoush/zsh zsh -c "cd /all$(pwd) && $*"
|
||||||
|
}
|
||||||
|
|
||||||
|
sdoc() {
|
||||||
|
docker run -it --rm -v "$HOME:/root" -v "/:/all:ro" mhoush/zsh zsh -c "cd /all$(pwd) && $*"
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue