In the Build Larabook from scratch Laracast tutorial, it is required to synchronize the local folder of the app with the virtual machine (Homestead) and vice versa.
To simplify development, the tutorial recommends to create the following alias:
ssh vagrant#127.0.0.1 -p 2222
by placing alias vm="ssh vagrant#127.0.0.1 -p 2222" in an ~/.aliases file, which I did.
This lets the narrator simply type the vm command from the local app folder to launch the virtual machine.
When I try to do so, I get -bash: vm: command not found
Did I miss something?
Related
I'm trying to find some way to be able to both use my company's VPN and Docker-Machine; at the moment, I cannot use both, or else if I use the VPN at any point, then I cannot do anything Docker related until I shut off the VPN and restart my machine. Specifically, the following command just hangs and times out:
eval $(docker-machine env dev)
where dev is the name of my Docker-Machine VM.
Nothing involving Docker works without that eval command, and the eval command simply does not work either while connected to the VPN or even after. I've read that using an older version of VirtualBox (4.3.1 or some such) will fix this issue, but unfortunately, Docker Toolbox always makes sure that the latest VirtualBox is installed. I'm using Docker Toolbox 1.8.1b and VirtualBox 5.0.2. Is there a way to get Cisco AnyConnect VPN and Docker-Machine to work together? It seems like the main problem is that AnyConnect is messing with network routing.
I'm sure a clever bash person could explain why, but eval "$(docker-machine env dev)" (note the quotes) is the recommended (by Docker) way to setup the DOCKER environment variables.
This answer applies the findings from: https://stackoverflow.com/a/26913705/3471672
I'm using the Toolbox on Mac OS X (Docker v1.10) from: https://docs.docker.com/mac/step_one/
It looks like the issue is a firewall rule introduced by starting Cisco AnyConnect. The following shows the issue getting introduced and how to resolve it:
Make sure Cisco AnyConnect is STOPPED (!)
Make sure you can see no firewall rule issue; to validate, run (using the Toolbox, in the Docker Quickstart Terminal):
$ sudo ipfw -a list | grep "deny ip"
Create docker machine named e.g.: dev, run:
$ docker-machine create --driver virtualbox dev
Validate the machine can be accessed, run e.g.:
$ docker-machine ls
START Cisco AnyConnect: --- THE ISSUE GETS INTRODUCED HERE ---
Validate the machine cannot be accessed anymore, run:
$ docker-machine ls
You will see an error like:
Unable to query docker version [...] connect: permission denied
Check for a new firewall rule that has been introduced, run:
$ sudo ipfw -a list | grep "deny ip"
You get something like e.g.:
00411 72 6160 deny ip from any to any keep-state
Based on the first number (in this case: 00411), remove the rule, run e.g.:
$ sudo ipfw delete 00411
Validate the machine can be accessed again, run:
$ docker-machine ls
Now you can successfully do stuff again like:
$ eval $(docker-machine env dev)
$ docker ps
etc.
I'm trying to run the container of postgres image with boot2docker on OSX.
This command works well on my Ubuntu:
docker run -v $(pwd)/data:/var/lib/postgresql/data postgres
but OSX says:
fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... initdb: could not create directory "/var/lib/postgresql/data/global": Permission denied
initdb: removing contents of data directory "/var/lib/postgresql/data"
chmod doesn't help.
I've tried option --user $(id -u):$(id -g). It breaks container on Ubuntu, and it changes the error on OSX.
Ubuntu: chmod: changing ownership of ‘/var/lib/postgresql/data’: Operation not permitted
OSX: chmod: changing permissions of ‘/run/postgresql’: Operation not permitted
As it works for Ubuntu I want to run it on OSX, without creating my own images.
But I have no idea how to deal with this error.
Any ideas?
I think this is a known boot2docker issue
There's several workarounds but no solution there
#1) Overriding the /Users default share on boot2docker start:
boot2docker --vbox-share=$(pwd)/share-location=share-name up
#2) boot2docker ssh in and mount the custom share:
sudo mount -t vboxsf -o uid=999,gid=50 share-name [SHARE-FULL-PATH]/share-location
Mounting local folders into docker containers is not a good practice. It quite often results into problems with file permissions.
The better solution would be to change your setup using a volume container instead. There are also good concepts for volume container backups.
I vagrant up a project, but accidentally delete the Vagrantfile folder, the VM is still in VirtualBox, how to rebuild the vagrantfile and assign it to the same VM.
You cannot rebuild Vagrantfile. But you can associate your folder with existing vm.
Short step-by-step (based on this link):
create file named .vagrant
run $ VBoxManage list vms in your terminal
get id hash for desired machine.
put into .vagrant this code: {"active":{"default":"YOUR-ID-HERE"}}
So you'll get something like this: {"active":{"default":"ec426377-dbe6-4be7-4751-766956e44958"}}
run $ vagrant init (this will create new Vagrantfile)
run $ vagrant up (this will associate your desired folder with running vm)
run $ ssh-keygen -t rsa -f .vagrant/machines/default/virtualbox/private_key
run $ ssh-copy-id -i .vagrant/machines/default/virtualbox/private_key.pub -p 2222 vagrant#127.0.0.1, password: vagrant
I don't think there is a way to do that (create a Vagrantfile from an existing VM). From the perspective of Vagrant virtual machines being temporary in nature (build, use, destroy), you're best bet may be to recreate the Vagrantfile again and start over.
If there is something on the VM that you want or need, you could access it directly via VirtualBox, then copy over to the new VM as needed.
I've installed boot2docker (full install) on Windows 7 and am trying to run the container port redirection demo:
docker run --rm -i -t -p 80:80 nginx
Which looks like it isn't quite finishing properly, it just stops and looks like this:
When I open another git bash shell and run boot2docker ip I get 192.168.59.103, and when I pop that in chrome I get Error code: ERR_CONNECTION_TIMED_OUT
It works fine for me with plain docker on Ubuntu 14.04. What else do I need to do to make it work with boot2docker on windows?
Looking more closely, my problem is the same as this question: Docker, can't reach “rails server” development from localhost:3000 using docker flag -p 3000:3000
The answer to that question that worked for me was this one, which simply says to run
boot2docker ssh -L 8080:localhost:80
at the terminal before starting boot2docker
In my case I do this (from a git bash terminal):
boot2docker init # from https://github.com/boot2docker/boot2docker
boot2docker up
boot2docker ssh -L 8787:localhost:8787 # sets up port forwarding and starts boot2docker
docker run -d -p 8787:8787 cboettig/rstudio # starts the container I want
then go to my web browser in windows and point it to http://localhost:8787/ and I get a server instance of RStudio. When I'm done:
docker rm -f $(docker ps -a -q) # delete all containers
UPDATE: downgrading to an earlier version of VirtualBox will fix this
After struggling with folder sharing I regressed through previous versions of VirtualBox and found that with version 4.3.12 I could enable folder sharing and have the port forwarded exactly according to the official instructions, that is I could access my docker container at 192.168.59.103. So downgrading VirtualBox is another option for working around this problem.
ANOTHER UPDATE: updating to the new release of v1.3.1 of boot2docker will fix this
This release just came out a week ago and includes VirtualBox Guest Additions, which simplifies all of this. I now simply do
boot2docker ssh # start boot2docker
docker run -d -p 8787:8787 -v /c/Users/foobar:/home/rstudio/foobar rocker/rstudio
And I get everthing working as expected and can log into RStudio in my browser at http://localhost:8787/ (linux) or http://192.168.59.103:8787 (Windows) and it just works.
In this case I've also got folder sharing working with, /c/Users/foobar corresponding to an existing folder on my computer at C:/Users/foobar, and foobar can be anything. With this method I can read and write files both ways between Windows and RStudio and I don't need to connect to a special IP address like the samba method does in the official docs
I had this problem too after a couple of failed attempts to boot2docker start. This created multiple entries of host-only networks configured on VirtualBox (VirtualBox Host-Only Ethernet Adapter #2, VirtualBox Host-Only Ethernet Adapter #3), and probably the boot2docker's VM was using a bad one.
I cleaned up using Virtualbox standard UI, leaving only one of the networks and now everything works fine.
I'm using boot2docker 1.5.0.
Just to register something that happened to me, and made me lose a couple of hours.
Following this tutorial on the Vagrant website, I was able to get a virtual machine up and running very easily, but now I'm trying to create a different virtual machine by forking a repository linked below.
The README in this repository tells me to do this:
$ git clone git://github.com/honza/django-chef.git
$ cd django-chef
# add yourself to the "users" array in the Vagrantfile
$ sudo echo "127.0.0.1 example.example.com" >> /etc/hosts
$ vagrant up
$ fab vagrant:honza bootstrap # replace with your name
$ vagrant ssh
$ run # ME (doctordoder): This command is not found?
"Then open your browser to http://example.example.com:3456."
The difference being that the other tutorial stops at vagrant up, and then the website is available.
When I tried to do these extra steps with this more difficult repository, I got this (I did these commands after I had already ran vagrant up in the django-chef directory successfuly):
Where is this so called "run" command in vagrant? Why do I need it? And why is it unavailable to me?
Because it's not a vagrant command :) It's a custom command that's put in by the chef provisioner.
I scanned the source code of the repository and you can find a .erb template in the following folder:
django-chef/cookbooks/example/templates/default/bashrc.erb [line 23]
within this file there is a custom function defined named "run". This function will execute the "runserver" command form django (link)
The file
django-chef/cookbooks/example/recipes/default.rb [line 23]
is responsible for updating the .bashrc file on the guest machine and that's why you can call the "run" command from inside the guest machine.
So basically you are looking at the wrong place.