Created
December 1, 2022 15:11
-
-
Save sergio-fry/033a6a93370b09763c1f48850548b56e to your computer and use it in GitHub Desktop.
docker run helpers
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
docker_dev_home=$HOME/.docker-dev | |
project_name=${PWD##*/} | |
image_name=`echo $project_name | tr '[:upper:]' '[:lower:]'`-dev | |
docker create --name $image_name-volumes -v "/usr/local/bundle" -v "/root/.gradle" busybox || true | |
if [ -f "Dockerfile.dev" ] | |
then | |
docker build -t $image_name -f Dockerfile.dev . | |
else | |
docker build -t $image_name . | |
fi | |
extra_args=$DOCKER_EXTRA_ARGS | |
if [ -f ".rbenv-vars" ] | |
then | |
extra_args="$extra_args --env-file .rbenv-vars" | |
fi | |
IP=$(ifconfig en0 | grep inet | awk '$1=="inet" {print $2}') | |
count=`lsof -n -i -P | grep -i TCP | grep socat | grep 6000 | wc -l | awk '{print $1}'`; | |
if [ "$count" == 0 ] | |
then | |
socat TCP-LISTEN:6000,bind=${IP},reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\" & | |
fi | |
docker-term-run $extra_args -e DOCKER_PROJECT_NAME=$project_name -e DISPLAY=$IP:0 --volumes-from $image_name-volumes $image_name $@ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
docker run --rm \ | |
-v "$PWD:/root/current" \ | |
-v "$HOME/.bashrc:/root/.bashrc:ro" \ | |
-v "$HOME/.bash_completion:/root/.bash_completion:ro" \ | |
-v "$HOME/.bash_aliases:/root/.bash_aliases:ro" \ | |
-v "$HOME/.bash_eternal_history:/root/.bash_history" \ | |
-v "$HOME/Desktop:/root/Desktop" \ | |
-v "$HOME/code:/root/code" \ | |
-e "HISTSIZE=-1" -e "HISTFILESIZE=-1" -e "DOCKER=true" \ | |
-w /root/current $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment