Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to pass docker socket as volume? #37

Closed
megastef opened this issue Nov 13, 2016 · 11 comments
Closed

How to pass docker socket as volume? #37

megastef opened this issue Nov 13, 2016 · 11 comments

Comments

@megastef
Copy link
Contributor

Hi,

the volume entry in the template is a simple array. How could i pass
-v /var/run/docker.sock:/var/run/docker.sock?

I'm working on a template entry and access to docker socket is mandatory for it, see: https://gist.github.com/megastef/0a97da2cecd619e643edf2a1307c6fb4

Ahh, one more question - is there an option to run a global Swarm service via template?

Thx
Stefan

@deviantony
Copy link
Member

Hi @megastef,

Our template system does not support bind mounts currently. Only volumes. When you declare a volume in a template definition, Docker will automatically create a volume and map it to the path specified in the template.

So in your case, you won't be able to achieve what you want... yet.

And, no, templates are container only for now and Swarm services are not supported... yet.

@otisg
Copy link

otisg commented Jan 21, 2017

@deviantony I think I saw demos/videos of Portainer and Swarm the other day. Is access to docker.sock possible now, as @megastef asked above? Or does this depend on #42?

@deviantony
Copy link
Member

@otisg still not possible inside a template definition. This is not related with #42 (ability to specify a command for a template, e.g. echo test for example).

Did you saw something related to this issue in the demo?

@deviantony
Copy link
Member

deviantony commented Feb 11, 2017

Hi @otisg @megastef

Once portainer/portainer#587 is implemented, you will be able to define the path to the Docker socket inside the volumes field such as volumes: ["/var/run/docker.sock"] and you'll be able to map any volume/host path onto it from the UI.

See portainer/portainer#590 for the implementation and an example.

@deviantony
Copy link
Member

This is now integrated in Portainer 1.12.

@megastef
Copy link
Contributor Author

@deviantony Great, thank you! I will make a PR with the template soon.

@deviantony deviantony reopened this Mar 14, 2017
@deviantony
Copy link
Member

Reopened, we need to find a way to easily bind the Docker socket in the templates.

Detailed problem in #52

@megastef
Copy link
Contributor Author

megastef commented Mar 20, 2017

Hi, could I suggest a format for volumes?

"volumes": [
  {
    "source": "/var/run/docker.sock",
    "target": "/var/run/docker.sock",
    "type": "bind"
  } 
 ]

The settings specified would be the defaults in the Portainer UI.
It should not be a problem in JavaScript to have mixed format with old and new format (as you could check for String or Object type and required properties).

BTW, you could get some inspiration in the Rancher Catalog for app templates, UI settings etc.
https://github.com/rancher/community-catalog/tree/master/templates/sematext

Basically there is one file mapping UI entries to variable names, and kind of docker-compose file using the variables, entered by the user.

@megastef
Copy link
Contributor Author

Any progress here?
In my PR #52
the Docker socket was working. Users had to choose the right binding manually, but it worked.
Why don't you simply check for the Docker socket path to set it right.
As we see there are more tools with the need of this feature.

@deviantony
Copy link
Member

@megastef see portainer/portainer#777 for the evolution on this

@deviantony
Copy link
Member

portainer/portainer#777 has been implemented ! Docs available via http://portainer.readthedocs.io/en/stable/templates.html#volumes

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

No branches or pull requests

3 participants