Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

Flexible Local Folder for Volumes #1202

Closed
wants to merge 6 commits into from
Closed

Conversation

alexandrev
Copy link
Contributor

This change allows to define Volumes where the local folder is not limited to the Users directory but to any folder mounted in the VM.

It recovers from the VBoxManage the mounted folders and it checks the final folder agains this values, and if it matches it allows to specify the path.

This code is related to Issue #1192 opened as a question.

Please, if you have any question, only let me know.

Signed-off-by: Alexandre Vazquez alexandre.vazquez@gmail.com

@FrenchBen
Copy link
Contributor

👍 thanks for creating this PR - I'll check it out tomorrow, but at first glance it seems that you found a good way to check for shared folders.

Can you confirm that this also compiles properly on Windows?

@alexandrev
Copy link
Contributor Author

Yeah, I'm using Windows as dev environment so I only could check it works
properly on Windows platform.

My current version is W10 Build 10586.

I'm sure we can optimize the code but I think it's a good first approach to
get it done.

Anything you can reach me here :)
On Nov 11, 2015 05:57, "French Ben" notifications@github.com wrote:

[image: 👍] thanks for creating this PR - I'll check it out tomorrow,
but at first glance it seems that you found a good way to check for shared
folders.

Can you confirm that this also compiles properly on Windows?


Reply to this email directly or view it on GitHub
#1202 (comment).


if (!directory || directory.indexOf(util.home()) === -1) {
var founded = false;
if(directory){
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you fix the indentation and check that spacing around keywords 'if' are respected?

@alexandrev
Copy link
Contributor Author

Hi @FrenchBen, Sorry for the things you point out. You are absolutely right. My bad! I think I push all the changes you requested. Please, take a look if now is OK for you and sorry again.

@@ -82,6 +82,9 @@ export default {
machineVersion
});

virtualBox.getShareDir(machine.name());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a user adds a shared directory, it will only be seen until the next kitematic restart - Is this the correct approach?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What you are comment is totally right. I think that the operation of add a new folder to the machine is not a "normal" activity when you are working, it is more usual an activity you do so few times when you are configuring your enviroment. So, I think recovering once when the program starts is enough, but if you think it's better another approach we can do this call when anyone is trying to change the volume..

I'm open to all your considerations, you are the master here :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haha no such thing as the master, just an observation. I think you're right, the user would add more folders and restart or start kitematic after making the changes.
When in doubt restart, right?

@FrenchBen
Copy link
Contributor

Doing some QA on the code you currently have I'm having a couple of issues while using the hello-world-nginx

  • After adding a Volume, trying to remove it, I get the following JS error:
    ContainerSettingsVolumes.react.js:132 Uncaught TypeError: Cannot read property 'replace' of null

Also mounting a volume on my Desktop (within the user dir), removing it and closing kitematic and opening it again, I get the following within your repo:

bad-volume

I confirmed this doesn't happen on Master.

@alexandrev
Copy link
Contributor Author

Hi @FrenchBen , sorry to hear that, I'm going to try to reproduce it here, and see which is the root cause. I'll get back to you.

@alexandrev
Copy link
Contributor Author

Hi @FrenchBen , I think I fix the bug you pointed out. The problem was I removed the "No Folder" condition and when the source was null, it crashes! Sorry! My bad!

please, check it now and if you have any problem, I could fix it right away!

@alexandrev
Copy link
Contributor Author

Any more feedback on this PR? Thx!

@FrenchBen
Copy link
Contributor

Wont' be able to look at it till monday - meanwhile, can you squash your commits into logical commits, instead of the multiple "fix this" "removed that"?

@alexandrev
Copy link
Contributor Author

Of course I will do. Thanks for everything

-- Sent from my mobile phone. Please excuse any typo.
On Nov 26, 2015 03:35, "French Ben" notifications@github.com wrote:

Wont' be able to look at it till monday - meanwhile, can you squash your
commits into logical commits, instead of the multiple "fix this" "removed
that"?


Reply to this email directly or view it on GitHub
#1202 (comment).

@kotowick
Copy link

kotowick commented Dec 1, 2015

Excited for this feature! Anyone have an ETA?

@alexandrev
Copy link
Contributor Author

Hi @FrenchBen . I have squashed the commits here as well to fix the same thing that you reported in the other PR . I hope with this change everying is OK.

Regarding to the @kotowick we are doing some QA to see that there is no bugs in the PR before any kind of merge. Regarding to the merge I have no clue about that but I'd like to be soon!!! 👍

@kotowick
Copy link

kotowick commented Dec 3, 2015

Thanks @alexandrev, looking forward to this feature 👍

@kotowick
Copy link

@alexandrev @FrenchBen hoping to have this in the next release?

@FrenchBen
Copy link
Contributor

I mounted a folder from the tmp dir in VirtualBox and made it 'automount' + 'permanent'
folder

I then opened Kitematic based on your PR, created a container based on the kitematic/hello-world-nginx and tried to mount a folder outside of the mounted volume and got the proper error 👍
When I tried to mount the volume in tmp, everything went well and it reported the volume as mounted.

The problem was that the 'index.html' file that normally gets created/copied into the volume mounted, didn't get copied.

Are you able to replicate this issue? If so, do you know why this is happening?

@alexandrev
Copy link
Contributor Author

I'm going to try to reproduce it, and I'll come back to you with some answers :)

@alexandrev
Copy link
Contributor Author

Hi @FrenchBen,

I'm going to describe my steps to reproduce the issue you are facing. Please, let me know if I'm doing something wrong to do it.

First, I add a new local folder inside the Docker VM machine, as you can see here:

image

Then, I specify the mapping in the Volume section as you can see here:

image

I start the container as you can see here:

image

And I can found the index.html file inside the DockerVM file:

image

Is everything OK? Or am I missing something?

Thanks!

@FrenchBen
Copy link
Contributor

Weird on my machine, going to D:\Temporal there was no file created - What permissions did you give the folder when you mounted it via VirtualBox?

@alexandrev
Copy link
Contributor Author

I don 't do anything special to get it mounted. I even not mount the
folder myself but I let the boot2docker machine do it for me when I restart
the container after changing the volume settings to the new path.

-- Sent from my mobile phone. Please excuse any typo.
On Dec 15, 2015 1:06 AM, "French Ben" notifications@github.com wrote:

Weird on my machine, going to D:\Temporal there was no file created -
What permissions did you give the folder when you mounted it via VirtualBox?


Reply to this email directly or view it on GitHub
#1202 (comment).

@FrenchBen
Copy link
Contributor

My question was how you add the folder to VirtualBox?

@alexandrev
Copy link
Contributor Author

Here you are, my virtual box shared folder configuration:

image

@alexandrev
Copy link
Contributor Author

Thanks to you because without your script, this could never be posible :)

@alexandrev
Copy link
Contributor Author

@FrenchBen maybe you could take a look at this and give us your comments :)

@alexandrev
Copy link
Contributor Author

Any more QA have been done? @JeffDM , what do you think about the feature and the code? Any comment?

@im-evo
Copy link

im-evo commented Feb 18, 2016

I've been using this branch on a daily basis for past few days and encountered no problems. Would love to see this in production.

@alexandrev
Copy link
Contributor Author

Ok!! Thank you @extra-0. @JeffDM and @FrenchBen does it look good for you?

@kotowick
Copy link

@alexandrev compiled and works well for me - haven't ran into any issues.

Thanks for doing this!

@FrenchBen let's get this merged :)

@im-evo
Copy link

im-evo commented Feb 27, 2016

@FrenchBen Any particular reason for this not to be merged? Anything needs to be changed?

@FrenchBen
Copy link
Contributor

@extra-0 I'd like for the solution to be within boot2docker more than a hack from our side to get it working - Having sudo anything as part of the script scares me a bit.

This only solves the kitematic side of things, when this could benefit all other users (cli users) - If it's done accordingly within the boot2docker setup, then everyone can benefit from it.

@im-evo
Copy link

im-evo commented Mar 1, 2016

@FrenchBen I believe we didn't use any hacks. On the contrary, we exploited functionality that was already there in boot2docker. Isn't Kitematic all about automation? We just automated a process of mounting volumes as user changes settings or starts new containers.

It's extremely flexible and by my experience brings Kitematic users to the next level without binding them to use home folders only. Please, check it out!

@alexandrev
Copy link
Contributor Author

@FrenchBen, I don't see the problem of using sudo inside a VM. It's like using it inside a sandbox. Which is the worst thing could happen? the problem will be using it inside the host machine.

@extra-0 Do we have an issue open to boot2docker to handle this issue? Because I think we didn't open any issue there...

@im-evo
Copy link

im-evo commented Mar 1, 2016

@alexandrev I just browsed through your code again and found no mentions of sudo. Am I wrong?

Also, I suppose boot2docker doesn't have an issue with functionality we are using, but rather an issue with remounts after reboot. We could create a ticket in their repository, however mounts that are used by your version of Kitematic handle this in another way by mounting folders when they are needed.

@alexandrev
Copy link
Contributor Author

We have a sudo when we do the mkdir and mount inside the boot2docker
machine.

Yeah, I'm aware our action is different but if @FrenchBen as core maintener
thinks it is better to have the other approach, we should go for it.

Thx man!

On Tue, Mar 1, 2016 at 10:09 AM extra-0 notifications@github.com wrote:

@alexandrev https://github.com/alexandrev I just browsed through your
code again and found no mentions of sudo. Am I wrong?

Also, I suppose boot2docker doesn't have an issue with functionality we
are using, but rather an issue with remounts after reboot. We could create
a ticket in their repository, however mounts that are used by your version
of Kitematic handle this in another way by mounting folders when they are
needed.


Reply to this email directly or view it on GitHub
#1202 (comment).

@im-evo
Copy link

im-evo commented Mar 1, 2016

@FrenchBen @alexandrev There were several tickets and even a pull-request at boot2docker to fix this, however it has not yet been accepted and this issue does not get much attention in boot2docker.
boot2docker/boot2docker#1088
boot2docker/boot2docker#1086
boot2docker/boot2docker#1101
The worst that could happen is that boot2docker implements automount and @alexandrev 's mkdir and mount command within boot2docker machine wont' work and can be removed. However all of the other functionality would stay the same.
What do you think?

@FrenchBen
Copy link
Contributor

Sudo is targeted to run in a 'sandbox' but say something odd happens and the sudo runs on the user's laptop? I wouldn't want to be responsible for that.

Having the fix in boot2docker would make this work across cli and kitematic. Having the desktop app include more functionality than is available via the normal CLI seems a bit conter-intuitive. If you don't mind pinging the devs in your last issue first, it would be appreciated:
boot2docker/boot2docker#1133

If we don't see anything within the next 2 weeks then we can all vote to merge it and provide more power to Kitematic user :D

Agreed?

@alexandrev
Copy link
Contributor Author

I agree @FrenchBen. But I want to talk about the sudo "problem". The sudo
is only targeted to run inside the sandbox. If something odds happen and
the sudo executes on the real machine. Different alternatives:

a) Windows platform: Nothing happens.
b) MacOS X / Linux platforms: Nothing happens because it is going to
request your user's password to executes any command (in the case your user
belongs to the ones allowed to execute sudo on that machine).

Thanks!!

On Wed, Mar 2, 2016 at 1:11 AM French Ben notifications@github.com wrote:

Sudo is targeted to run in a 'sandbox' but say something odd happens and
the sudo runs on the user's laptop? I wouldn't want to be responsible for
that.

Having the fix in boot2docker would make this work across cli and
kitematic. Having the desktop app include more functionality than is
available via the normal CLI seems a bit conter-intuitive. If you don't
mind pinging the devs in your last issue first, it would be appreciated:
boot2docker/boot2docker#1133
boot2docker/boot2docker#1133

If we don't see anything within the next 2 weeks then we can all vote to
merge it and provide more power to Kitematic user :D

Agreed?


Reply to this email directly or view it on GitHub
#1202 (comment).

@alexandrev
Copy link
Contributor Author

Hi,

I want to review my open #PR and see if there is some need to change anything to merge them or close them if they are not needed. I don't know if this PR makes sense right know after the big change of Docker for Windows / Mac and the change from VirtualBox to Hyper-V and the other option on Mac. @FrenchBen do you need something from my side or do we close this PR?

Thanks!

@FrenchBen
Copy link
Contributor

FrenchBen commented Aug 8, 2016

I think this can be closed - I submitted a PR that checks for an existing Docker for Mac/Windows install and allow other folders to be mounted based on that.
Virtualbox will remain 'locked' to /Users

Are you ok with me closing it?

@FuriouslyCurious
Copy link

Everyone, please consider merging in code from @syardumi #376

Mac OS version is not able to mount any volumes from Kitematic, this change will help resolve that.

@alexandrev
Copy link
Contributor Author

@FrenchBen I think we have to focus on the newer versions Docker for Windows and Docker for Mac. So, if it is solved there. I'm ok with you closing it. But I think I need to push the transition to Kitematic for the new versions. Because right now it is very difficult to collaborate on things when the master repo seems to be more related to the 'old Virtualbox-based Kitematic'

The main idea here, is that all of us have to work on the same direction to do greater things :)

@FrenchBen
Copy link
Contributor

@alexandrev absolutely - I merged a couple of PR related to the changes for folders to be reachable outside of the Users directory.

@FrenchBen FrenchBen closed this Aug 31, 2016
@jhgorse
Copy link

jhgorse commented Sep 14, 2016

I am on macOS Sierra and it is not clear how to add new volumes as a result of this feature, particularly when virtualbox is not being used.

376 appears to address the issue of adding new volumes to the dockerfile.

@FrenchBen
Copy link
Contributor

@jhgorse the above feature only applies to native users. If you're on Docker for Windows, you simply need to use the settings window to add the volumes that should be shared. See:
https://docs.docker.com/docker-for-windows/#/shared-drives

@jhgorse
Copy link

jhgorse commented Sep 15, 2016

@FrenchBen I have what I believe to be the native docker-beta for macOS Sierra, which also has the shared directories (default /Users:/Volumes:/tmp:/private).

These do not appear in the Kitematic->Settings->Volumes settings.
Also, there is no option that I see to "Add a folder." <-- This is my main concern, which I believe to be related to #376. Even though #376 has been closed, the issue remains in the beta I have, 0.12.0 from July 27th, and in the screenshots above I do not see the capability to "Add a folder".

@FrenchBen
Copy link
Contributor

@jhgorse The 'add a folder' screenshot is from Virtualbox - Kitematic will not show any folder if the image that you're using doesn't have a volume directive.
Try something like the Kitematic nginx hello world and you'll see the folder option.

Adding a folder when one isn't declared in the image, has yet to be implemented with the latest changes. This was started in #722 which was closed in favor of this one, which solved only part of the issue.

@LiamKarlMitchell
Copy link

LiamKarlMitchell commented Aug 28, 2018

Still getting error.

image

I deleted the machine in virtual box.
Then ran this in the Docker Quickstart Terminal.

docker-machine rm default
docker-machine create --driver virtualbox --virtualbox-share-folder "e:\Docker:/c/project" default

@FrenchBen
If I just patch the validation checks in the UI files would it let me mount volumes from that directory? :)

Note: I am wanting to use VirtualBox on Windows 10 as I can't seem to use VBox with the native windows emulation at the same time and I have many VBox vm's. And the native windows way didn't work well with my computer/network card for some buggy reason it was unbearably laggy. (Broadcom)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants