Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jmaxwilson/wsl-docker-git-setup
Shell script to configure Windows Subsystem for Linux (WSL) & Ubuntu on Windows to use docker and docker-compose as well as a git-enabled prompt
https://github.com/jmaxwilson/wsl-docker-git-setup
bash-on-windows bash-prompt bash-script docker docker-compose docker-for-windows git ubuntu-on-windows windows-10 windows-subsystem-linux wsl
Last synced: about 1 month ago
JSON representation
Shell script to configure Windows Subsystem for Linux (WSL) & Ubuntu on Windows to use docker and docker-compose as well as a git-enabled prompt
- Host: GitHub
- URL: https://github.com/jmaxwilson/wsl-docker-git-setup
- Owner: jmaxwilson
- License: mit
- Created: 2018-04-05T01:19:11.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2021-08-27T03:58:33.000Z (over 3 years ago)
- Last Synced: 2024-08-13T07:16:06.726Z (5 months ago)
- Topics: bash-on-windows, bash-prompt, bash-script, docker, docker-compose, docker-for-windows, git, ubuntu-on-windows, windows-10, windows-subsystem-linux, wsl
- Language: Shell
- Homepage:
- Size: 417 KB
- Stars: 36
- Watchers: 3
- Forks: 8
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - jmaxwilson/wsl-docker-git-setup - Shell script to configure Windows Subsystem for Linux (WSL) & Ubuntu on Windows to use docker and docker-compose as well as a git-enabled prompt (Shell)
README
# wsl-docker-git-setup
This is a shell script that can be run in the **Ubuntu for Windows Bash** running on the **Windows Subsystem for Linux (WSL)** to configure Bash for development using commandline **Docker** and **Git** commands on **Windows 10**. This makes it much easier to run most of the same docker scripts on Windows that you do on Linux or Mac by using WSL and Ubuntu Bash instead of GitBash and Git for Windows.
## Prerequisits and Configuration
- Windows 10 Professional
- Windows Subsystem for Linux (WSL)
- Docker for Windows### Installing the Windows Subsystem For Linux
Instructions for installing the Windows Subsystem for Linux on Windows 10 and Ubuntu for Windows can be found at the official WSL website:
https://msdn.microsoft.com/en-us/commandline/wsl/install_guide(The installation may require a system restart)
Once installation is complete, you should be able to start Ubuntu for Windows from the start menu. This project also includes an example shortcut for starting Ubuntu Bash.
### Installing and Configuring Docker for Windows
Instructions for installing Docker for Windows can be found at the official Docker website:
https://store.docker.com/editions/community/docker-ce-desktop-windows
(The installatiion may require a system restart to enable Hyper-V)
Once Docker for Windows has been installed, you will need to configure it so that it can be accessed from the WSL bash.
- Right click the Docker Whale icon in system tray
- Select "Settings..."
- Under the "General" section
- Check the option to "Expose daemon on tcp://localhost:2375 without TLS"
- Under the "Shared Drives" section
- Check the C Drive
- Apply Changes (You may be prompted for your login credentials)## WSL Docker Git Setup Script
Git comes installed by default with Ubuntu for Windows. You can clone this repository immediately from your WSL Bash by running:
`git clone https://github.com/jmaxwilson/wsl-docker-git-setup.git`
Once the code has been cloned you can run `wsl-setup.sh` to configure your WSL Bash to be able to communicate with Docker for Windows and install a git-enabled commandline prompt that makes it easier to work with git from WSL.
`cd wsl-docker-git-setup`
`./wsl-setup.sh`
The interactive shell script:
- Creates `.bashrc_wsl` file that is sourced from `.bashrc` for customizing the bash
- Installs `docker-ce` and `docker-compose` and their dependencies for use on the commandline
- Adds a `DOCKER_HOST` environment variable in `.bashrc_wsl` to allow docker to connect to Docker for Windows
- Adds a symlink `/c` that points to the C drive shared by Docker for Windows (`/mnt/c`) so that docker paths will work properly
- Adds a Git enabled prompt so that you can see Git branch information on the commandline
- Sets the default directory when WSL Bash startsOnce the script has completed, you will need to exit bash and start it again for some of the changes to be applied.
You should be able to run `docker` and `docker-compose` commands from the WSL Ubuntu commandline on Windows as well as see git branch information in the command prompt.
You can test them by running:
`docker info``docker-compose version`
`docker run hello-world`
You can now run most of the same docker scripts on Windows that you do on Linux or Mac by using WSL and Ubuntu Bash.
![Animated GIF of Docker running in Ubuntu Bash running on Windows WSL](https://raw.githubusercontent.com/jmaxwilson/wsl-docker-git-setup/master/wsl-docker-git.gif "Example Docker running in Ubuntu Bash running on Windows WSL")
## Additional Customization and Install Scripts
This project also includes some additional scripts that are not run by the `./wsl-setup.sh` script but that can be run individually for additional customization:`./create-aliases.sh` - Creates aliases that override the default options for `ls` and `tree`
`./dircolors.sh` - Creates a `~/.dircolors` file that overrides the display colors of directories
`./git-dir-install.sh` - Creates a `git-dir` function to make it easy to run git commands on directories
`./golang-install.sh` - Installs [Go](https://golang.org) programming language support
`./nodejs-install.sh` - Installs [NodeJS](https://nodejs.org) programming language support