GithubHelp home page GithubHelp logo

babun-docker's Introduction

babun-docker

Description

Workaround and quick fix to allow using Docker Tooblox from Babun.

It could work for Cygwin with some little modifications, but if you are using Cygwin, you should be using Babun. It's an improved Cygwin.

This quick fix installs winpty, sets the environment variables and creates a function to embed docker, and to allow non-tty connections.

It also checks if the default docker-machine is running, if not, it tries to start it and set the environment to use it.

After using this, you don't have to "use" another program. You can keep using the docker commands as normal.

Installation

  • Install Babun and start a terminal.
  • Run the following command:
curl -s https://raw.githubusercontent.com/tiangolo/babun-docker/master/setup.sh | source /dev/stdin

Note: the previous command will get a script from this repository and run it immediately, performing all the needed steps to install everything (the same steps described in "Manual installation"). If you don't want to run it, you can do a manual installation.


Docker Volumes with Babun

If you want to set up Docker Volumes with Babun, to allow using commands like:

docker run -it -v $(pwd):/var/www ubuntu bash

Read this Wiki entry: Docker Volumes with Babun.


Manual installation

  • Go to your home directory:
cd
  • Create a directory to store winpty:
mkdir ~/.winpty
  • Enter that directory:
cd ~/.winpty
  • Download winpty for Cygwin:
wget https://github.com/downloads/rprichard/winpty/winpty-0.1.1-cygwin.zip
  • Unzip it there:
unzip winpty-0.1.1-cygwin.zip
  • Add execution permissions:
chmod 777 ~/.winpty
  • Add winpty to the PATH variable:
echo 'PATH=$PATH:'$WINPTY_DIR >> ~/.zshrc
  • Add the workaround function to your .zshrc:
echo '
# Fix for Docker and Docker Toolbox in Babun
if [[ -z "$docker_bin" ]] then ;
docker_bin=$(which docker) ;
fi
function docker {
result="$($docker_bin $@ 2>&1)"
if [[ $result == "cannot enable tty mode on non tty input" ]] ; then
 echo "babun-docker: Using winpty"
 console $docker_bin $@
elif [[ $result == *"ConnectEx tcp"* ]] ; then
 echo "babun-docker: Trying to start docker-machine default"
 docker-machine start default
 echo "babun-docker: Setting up docker-machine environment"
 eval "$(docker-machine env default --shell zsh)"
 docker $@
else
 echo $result ;
fi
}
BABUN_DOCKER_SETUP=1
' >> ~/.zshrc

The function will try to call docker, if it fails, it will check what was the failure, try to fix it and run again.

It will:

  • auto-start the default docker machine
  • set the environment variables for that default docker-machine
  • use winpty (console) to connect to a tty session to avoid errors, as in:
docker exec -it my_container bash

babun-docker's People

Contributors

tiangolo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.