When running any
vagrant command, you normally need to be in a folder containing a Vagrantfile.
In the case of ce-vm, it means you can only run vagrant commands from within the ce-vm folder of your project.
This script allows you to run vagrant commands from any directory within your project (provided the root is a git repository). To use it, add an alias of your choice (vg, vagrant, ce-vm, ...) to your .bashrc/.zshrc file.
alias vg="/bin/sh $HOME/.CodeEnigma/ce-vm/ce-vm-upstream/scripts/vagrant-wrapper.sh"
Note: You will need to have used ce-vm at least once before you can add the alias, else the script won't be present yet.
On Linux, the docker daemon is only accessible by the root user, meaning you are left with two choices:
- Running everything as root/sudo. This ends up being a mess of file permissions and ownership and is not really a practical option in a daily "local dev" environment.
- Adding your user to the "docker" group. This is convenient, and what most people end up doing, but poses a serious security issue.
This script tries to combine the best of both world by wrapping any
vagrant command, adding your user to the "docker" group before running it, then removing it straight after. It also combine the convenient vagrant-wrapper.sh feature.
Before you can use this script, you will need to have used ce-vm at least once. Which involves ... adding yourself to the "docker" group in the first place ! This is temporary, don't worry.
- Add yourself to the "docker" group:
sudo gpasswd -a "$USER" "docker"
- Logout and login from your session (rebooting is the safest)
- Test you can interact with the docker daemon without sudo: "docker ps -a"
- Follow the instructions as per the get started guide:
cd myproject/ce-vm && vagrant up
Then, to use it, add an alias of your choice (vg, vagrant, ce-vm, ...) to your .bashrc/.zshrc file.
alias vg="/bin/sh $HOME/.CodeEnigma/ce-vm/ce-vm-upstream/scripts/vagrant-docker-sudo.sh"
Note: Not all flavours of Linux have been tested, feel free to suggest ways of ensuring portability.