mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2026-04-10 04:26:17 +02:00
more docker help
This commit is contained in:
parent
4bc4455051
commit
641c9da07c
1 changed files with 66 additions and 17 deletions
|
|
@ -1,28 +1,76 @@
|
||||||
function dock_usage () {
|
function dock_usage () {
|
||||||
echo
|
cat <<-USAGE
|
||||||
echo " usage: dock <command>"
|
|
||||||
echo
|
usage: dock <command>
|
||||||
echo " clean Remove all containers";
|
|
||||||
echo " help show Docker cheat sheet";
|
clean Remove all stopped containers
|
||||||
|
info Info on Docker setup
|
||||||
|
help show Docker cheat sheet
|
||||||
|
USAGE
|
||||||
}
|
}
|
||||||
|
|
||||||
function dock_clean {
|
function dock_clean {
|
||||||
docker rm $(docker ps -a -q);
|
docker rm $(docker ps -a -q);
|
||||||
|
docker rmi $(docker images | grep "^<none>" | awk "{print $3}");
|
||||||
|
}
|
||||||
|
|
||||||
|
function dock_info {
|
||||||
|
cat <<-INFO
|
||||||
|
You are (probably) running docker locally on a Mac using Docker Toolbox.
|
||||||
|
|
||||||
|
Docker Machine is the new boot2docker thing. You have a virtual machine
|
||||||
|
created called 'default'. You can check the status by running.
|
||||||
|
|
||||||
|
docker-machine status default
|
||||||
|
|
||||||
|
If it's not 'Running', you can bring it up with docker-machine start
|
||||||
|
|
||||||
|
You should have this in your profile:
|
||||||
|
|
||||||
|
### Docker
|
||||||
|
export DOCKER_TLS_VERIFY="1"
|
||||||
|
export DOCKER_HOST="tcp://192.168.99.100:2376"
|
||||||
|
export DOCKER_CERT_PATH="/Users/nathan/.docker/machine/machines/default"
|
||||||
|
export DOCKER_MACHINE_NAME="default"
|
||||||
|
|
||||||
|
and, you should have this in your /etc/hosts
|
||||||
|
|
||||||
|
## Docker Machine
|
||||||
|
192.168.99.100 docker d
|
||||||
|
|
||||||
|
So, you can access local running containers, by going to:
|
||||||
|
|
||||||
|
http://d:<port of container>
|
||||||
|
INFO
|
||||||
}
|
}
|
||||||
|
|
||||||
function dock_help {
|
function dock_help {
|
||||||
echo
|
cat <<-HELP
|
||||||
echo " # build a tagged docker docker image";
|
# list local images
|
||||||
echo " docker build -t <tag name> <folder>";
|
docker images
|
||||||
echo
|
|
||||||
echo " # run a docker image as a daemon on a port";
|
# build a tagged docker docker image;
|
||||||
echo " docker run -d --name <give it a name> -p <inside port : outside port> <tag>";
|
docker build -t <tag name> <folder>;
|
||||||
echo
|
|
||||||
echo " # run bash in a container";
|
## Example:
|
||||||
echo " docker exec -ti <name, tag, or id> bash";
|
docker build -t chicksphotocracy/photoop:latest .
|
||||||
echo
|
|
||||||
echo " # tunnel to boot2docker";
|
# run a docker image as a daemon on a port;
|
||||||
echo " boot2docker ssh -L 5000:localhost:5000";
|
docker run -d --name <give it a name> -p <inside port : outside port> <tag>;
|
||||||
|
|
||||||
|
## Example:
|
||||||
|
docker run -t -i -p 5678:5678 chicksphotocracy/photoop:1.9.0
|
||||||
|
|
||||||
|
# run bash in a container;
|
||||||
|
docker exec -ti <name, tag, or id> bash;
|
||||||
|
|
||||||
|
# remove an image
|
||||||
|
docker rmi <tag, name, id>
|
||||||
|
|
||||||
|
# remove a container
|
||||||
|
docker rm <tag, name, id>
|
||||||
|
|
||||||
|
HELP
|
||||||
}
|
}
|
||||||
|
|
||||||
function dock () {
|
function dock () {
|
||||||
|
|
@ -30,6 +78,7 @@ function dock () {
|
||||||
dock_usage;
|
dock_usage;
|
||||||
else
|
else
|
||||||
[ "$1" = "clean" ] && dock_clean "$2"
|
[ "$1" = "clean" ] && dock_clean "$2"
|
||||||
|
[ "$1" = "info" ] && dock_info
|
||||||
[ "$1" = "help" ] && dock_help
|
[ "$1" = "help" ] && dock_help
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue