• This repository has been archived on 19/Sep/2021
  • Stars
    star
    170
  • Rank 223,357 (Top 5 %)
  • Language
    Shell
  • License
    MIT License
  • Created about 9 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Use Docker Toolbox with Babun (Cygwin) in Windows

babun-docker

🚨 DEPRECATED 🚨

If you are developing in Windows you will have a much better time using Docker for Windows and developing with WSL (Windows Subsystem for Linux) than using Babun and connecting it to Docker Toolbox. You probably shouldn't use this tool. It's here only for posterity.

Description

Program / fix to allow using Docker Toolbox from Babun or Cygwin in Windows.

If you are using Cygwin, you should be using Babun. It's an improved Cygwin. Nevertheless, the latest versions of babun-docker work in Cygwin too.

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

This allows running commands that "enter" in the container, as for example those that use -it and end in bash:

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

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

And it also sets up shared folders in VirtualBox for each drive in your Windows (although you can configure which drives to use if you want) and mounts them inside the virtual machine (docker-machine), to allow using volumes with Docker (from any drive in your Windows, which is even more than what comes by default with the Docker Toolbox) to allow using commands like:

docker run -d -v $(pwd):/var/www ubuntu ping google.com

The shared folders (drives) inside the docker-machine (VirtualBox virtual machine) are mounted in two different directories to make it compatible with docker and docker-compose, so you can use normal relative volumes with docker-compose. You only have to make sure you run a normal docker command first to start and set up everything. For example:

docker ps

Note: After installing babun-docker (this program), you don't have to "use" another program. You can keep using the docker commands as normal. And after running a first docker command, you can use docker-compose as you would normally too.

Installation

  • Install Docker Toolbox.
  • Run the bundled Docker Quickstart Terminal that comes with Docker Toolbox to make sure everything is working.
  • Turn off the Docker Toolbox Virtual Machine: run docker-machine stop default (or turn off the Virtual Machine default in VirtualBox) so that babun-docker can do all the needed automatic configurations with the VM turned off.
  • 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
  • To be able to use babun-docker right away without having to close and open Babun run the update:
babun-docker-update
  • From Babun, use Docker as you would normally, for example: docker ps.

It will take care of configuring the virtual machine, turning it on, sharing volumes, allowing non-tty commands, etc. Whenever it does something for you (automatically) you will see an output like: -- babun-docker: doing something.

Note: the installation 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.

Installing docker-babun in Cygwin

If you definitively don't want to use Babun, you can install docker-babun in Cygwin (nevertheless, I highly recommend you Babun).

First you will need to have installed the following packages (installed by default in Babun):

  • curl
  • wget
  • git

Then you can run the same command as above.

Updating

  • To update babun-docker, after following the installation instructions, run the command:
babun-docker-update

Note: if you want to receive email notifications when babun-docker is updated you can "star" this repository (the star button above) and login with GitHub to Sibbell, it will send you notifications automatically with new releases.

Turning off

  • As Docker Toolbox runs in a virtual machine, it uses docker-machine to comunicate and configure it. If you want to turn the virtual machine off, run:
docker-machine stop $babun_docker_machine_name

Release Notes

Latest changes

2018-04-27:

Updates (winpty) and bug fixes. See PR 34 by murray02.

The return code is now preserved. See PR 31 by ptisserand.

2016-11-09:

Now the shared folders are mounted in two directories inside the VirtualBox virtual machine to make it compatible with docker-compose.

You can start and set up babun-docker and all the shared folders with any docker command, as:

docker ps

And have a docker-compose.yml file with:

version: '2'
services:
  server:
    build: ./server
    volumes:
      - ./server/app:/app
    ports:
      - 8081:80

...note the relative mounted volume in ./server/app:/app.

And then bring up your stack with:

docker-compose up -d

and it will work (because the shared folder paths that docker-compose uses are also mounted in the virtual machine).

2016-08-17:

  • Fix for the command docker login, see PR 24 by jpraet.

2016-07-05:

  • Make winpty download file explicit, see PR 23 by murrayju.
  • Use the latest version of Winpty (0.4.0).

2016-06-22:

2016-04-21:

  • Now you can run babun-docker in Cygwin (but I still recommend Babun).

2016-04-20:

  • Update winpty to latest version (and make old winpty installs to auto-update).
  • Now you can use Bash instead of Zsh.

2016-04-19:

  • You can configure the VirtualBox installation path with the variable babun_docker_virtualbox_bin. Read more in the Configurations section below.

2016-04-14:

  • You can define which specific Windows drives to mount with the variable babun_docker_volumes (by default babun-docker tries to mount them all). Read more in the Configurations section below.

  • You can use a separate file in ~/.babun-docker/custom-config.sh for custom configurations. Read more in the Configurations section below.

  • Improved mounted volumes and ownership (with hints by @olegweb ).

2016-03-16:

2015-11-12:

  • babun-docker automatically sets up shared folders in your VirtualBox virtual machine (docker-machine) for each of your Windows drives and mounts them inside the virtual machine, to allow using volumes (from any drive in your Windows, which is even more than what comes by default with the Docker Toolbox) with commands like:
docker run -it -v $(pwd):/var/www debian bash
  • You can configure if you want babun-docker to automatically set up VirtualBox shared folders and volumes with the environment variable babun_docker_setup_volumes. Set it to "0" if you want to disable that. Read more in the Configurations section below.

  • You can now specify the name of the docker-machine to use with the environment variable babun_docker_machine_name, which is set by default to the "default" machine (named "default"). (No pun / tongue twister intended). Set that environment variable to the name of the machine that you want to use (e.g. babun_docker_machine_name='dev'). Read more in the Configurations section below.

2015-10-21:

  • The installation of babun-docker clones the repository and sets up the environment to use the scripts inside it instead of writing it all to the ~/.zshrc file.

  • Running babun-docker-update will update that repository (will update babun-docker) and set up the environment again.


Docker Volumes with Babun

Here is an explanation of how volumes work in Docker and how they work in the Toolbox Virtual Machine: Docker Volumes with Babun.

That's what allows using commands like:

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

But all that is implemented automatically in the newest version of babun-docker.


Manual installation

  • Go to your home directory:
cd
  • clone this repo in the specific directory, like:
git clone https://github.com/tiangolo/babun-docker.git ./.babun-docker
  • Enter that directory:
cd ./.babun-docker
  • Source the setup:
source ./setup.sh

The setup will:

  • Download and install Winpty to allow using Docker commands that enter a container
  • Create a command (function) to update babun-docker, with babun-docker-update
  • Add itself to the ~/.zshrc file to run at startup
  • Run (source) the script to fix Docker, wrapping it

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

The wrapper / fix 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

Configurations

After installing babun-docker, you can configure things with environment variables in the file ~/.babun-docker/custom-config.sh.

  • If you want to specify which drives should be used for the setup of VirtualBox shared folders and volumes inside your docker-machine virtual machine set the environment variable babun_docker_volumes to a list of the drive names separated by spaces, as in "c d". For example:
echo 'babun_docker_volumes="c d"' >> ~/.babun-docker/custom-config.sh
source ~/.babun-docker/*config.sh
  • If you want to disable the setup of VirtualBox shared folders and volumes inside your docker-machine virtual machine set the environment variable babun_docker_setup_volumes to "0". For example:
echo babun_docker_setup_volumes=0 >> ~/.babun-docker/custom-config.sh
source ~/.babun-docker/*config.sh
  • If you want to change the virtual machine to use (if you have configured another virtual machine with docker-machine) you can set the environment variable babun_docker_machine_name to the name of your new virtual machine. For example:
echo babun_docker_machine_name='dev' >> ~/.babun-docker/custom-config.sh
source ~/.babun-docker/*config.sh
  • If you have VirtualBox installed in a different location (it would be uncommon) you could set the path with the variable babun_docker_virtualbox_bin, you would have to use Cygwin (Babun) paths, you can use cygpath to convert between Windows and Cygwin paths. It should point to the program "VBoxManage". For example:
echo "babun_docker_virtualbox_bin='$(cygpath -u 'C:\Program Files\Oracle\VirtualBox\VBoxManage')'" >> ~/.babun-docker/custom-config.sh
source ~/.babun-docker/*config.sh

License

This project is licensed under the terms of the MIT license.

More Repositories

1

fastapi

FastAPI framework, high performance, easy to learn, fast to code, ready for production
Python
73,897
star
2

full-stack-fastapi-template

Full stack, modern web application template. Using FastAPI, React, SQLModel, PostgreSQL, Docker, GitHub Actions, automatic HTTPS and more.
TypeScript
24,890
star
3

typer

Typer, build great CLIs. Easy to code. Based on Python type hints.
Python
14,943
star
4

sqlmodel

SQL databases in Python, designed for simplicity, compatibility, and robustness.
Python
13,694
star
5

uwsgi-nginx-flask-docker

Docker image with uWSGI and Nginx for Flask applications in Python running in a single container.
Python
2,986
star
6

uvicorn-gunicorn-fastapi-docker

Docker image with Uvicorn managed by Gunicorn for high-performance FastAPI web applications in Python with performance auto-tuning.
Python
2,699
star
7

asyncer

Asyncer, async and await, focused on developer experience.
Python
1,517
star
8

pydantic-sqlalchemy

Tools to convert SQLAlchemy models to Pydantic models
Python
1,173
star
9

nginx-rtmp-docker

Docker image with Nginx using the nginx-rtmp-module module for live multimedia (video) streaming.
Dockerfile
1,110
star
10

dockerswarm.rocks

Docker Swarm mode rocks! Ideas, tools and recipes. Get a production-ready, distributed, HTTPS served, cluster in minutes, not weeks.
Python
1,093
star
11

uwsgi-nginx-docker

Docker image with uWSGI and Nginx for applications in Python (as Flask) in a single container.
Python
646
star
12

uvicorn-gunicorn-docker

Docker image with Uvicorn managed by Gunicorn for high-performance web applications in Python with performance auto-tuning.
Python
628
star
13

full-stack

Full stack, modern web application generator. Using Flask, PostgreSQL DB, Docker, Swagger, automatic HTTPS and more.
Python
523
star
14

meinheld-gunicorn-flask-docker

Docker image with Meinheld and Gunicorn for Flask applications in Python.
Python
486
star
15

full-stack-fastapi-couchbase

Full stack, modern web application generator. Using FastAPI, Couchbase as database, Docker, automatic HTTPS and more.
Python
440
star
16

typer-cli

Run Typer scripts with completion, without having to create a package, using Typer CLI.
Python
367
star
17

poetry-version-plugin

Poetry plugin for dynamically extracting the package version from a __version__ variable or a Git tag.
Python
361
star
18

fastapi-cli

Run and manage FastAPI apps from the command line with FastAPI CLI. 🚀
Python
287
star
19

blog-posts

Blog posts and related code by Sebastián Ramírez (@tiangolo)
Python
273
star
20

uvicorn-gunicorn-starlette-docker

Docker image with Uvicorn managed by Gunicorn for high-performance Starlette web applications in Python with performance auto-tuning.
Python
182
star
21

latest-changes

A GitHub Action to add latest changes after each PR merged automatically
Python
172
star
22

meinheld-gunicorn-docker

Docker image with Meinheld managed by Gunicorn for high-performance WSGI (Flask, Django, etc) web applications in Python with performance auto-tuning.
Python
165
star
23

docker-with-compose

Docker image with Docker Compose installed for CI.
Shell
158
star
24

node-frontend

Instrutctions to buid a frontend Docker image built with Node.js and then served with Nginx. Previously a Docker image.
Dockerfile
137
star
25

flask-frontend-docker

Minimal project generator with a Flask backend, a modern frontend (Vue, React or Angular), a Traefik load balancer with HTTPS, all based on Docker.
Vue
130
star
26

python-machine-learning-docker

Docker image with Python 3.6 and 3.7 using Conda, with CUDA variants. To serve as base image for Machine Learning projects.
Dockerfile
84
star
27

uvicorn-gunicorn-machine-learning-docker

Docker image for high-performance Machine Learning web applications. With Uvicorn managed by Gunicorn in Python 3.7 and 3.6, using Conda, with CUDA and TensorFlow variants.
Python
67
star
28

issue-manager

Automatically close issues that have a label, after a custom delay, if no one replies back.
Python
62
star
29

full-stack-flask-couchbase

Full stack, modern web application generator. Using Flask, Couchbase as database, Docker, Swagger, automatic HTTPS and more.
Python
59
star
30

label-approved

Label a Pull Request after a number of approvals
Python
34
star
31

full-stack-flask-couchdb

Full stack, modern web application generator. Using Flask, CouchDB as database, Docker, Swagger, automatic HTTPS and more.
Python
31
star
32

tiangolo

16
star
33

github-actions-sandbox

Not useful for you. It's just a sandbox GitHub repo for me to try out stuff and develop GitHub Actions.
Python
16
star
34

tiangolo.com

Python
16
star
35

docker-auto-labels

Generate each Docker constraint label in random nodes in the cluster.
Python
15
star
36

angular-docker-multi-stage-example

Angular in Docker with Nginx, supporting environments, built with multi-stage Docker builds
15
star
37

ngx-http-client

Angular (4.3+) HttpClientModule with parameter encodings compatible with back ends (Node.js, Python, PHP, etc)
TypeScript
11
star
38

compose-to-rancher

Convert Docker Compose V2 to Rancher compatible Docker Compose V1
Python
10
star
39

markdown-include-variants

Markdown extension to expand directives to include source example files to also include their variants. Only useful to tiangolo's projets. Don't use it. 😅
Python
9
star
40

wunderlist2csv

Convert from Wunderlist backup json file to a CSV file importable by TaskCoach
Python
6
star
41

anaconda_cluster_install

Automatically Install Anaconda Python in a cluster of machines, for a specified user.
Shell
5
star
42

bitbucket_issues_to_redmine_csv

Python
3
star