SvenDowideit / dockerfiles

dockerfiles that I use
http://fosiki.com
MIT License
212 stars 59 forks source link

Samba - nothing to share + fix #38

Open niccokunzmann opened 8 years ago

niccokunzmann commented 8 years ago

Observation When I run

docker run -v /data --name my-data busybox true 
docker run --rm -v /usr/local/bin/docker:/docker -v /var/run/docker.sock:/docker.sock svendowideit/samba my-data

I get

my-data has no volumes - nothing to share.

Fix

The error is in line 90. When I run

docker inspect --format="{{range \$k,\$v := .Volumes}}{{println \$k}}{{end}}" my-data

I get no output. But, when I add .Config it works.

docker inspect --format="{{range \$k,\$v := .Config.Volumes}}{{println \$k}}{{end}}" my-data

Output:

/data

Docker Version: 1.9.1 API Version: 1.21

Solution

I guess this is due to old docker versions that hat a .Volumes attribute. I suggest the following:

  1. Keep the old query intact in case there is an old version
  2. Add a new query with .Config
niccokunzmann commented 8 years ago

Pull request 32 fixes this.

larrycai commented 8 years ago

To my case under 1.9.1, I just see null under .Config.Volumes , therefore I can't use samba now. Any hints ?

   "Config": {
        ...
        "Cmd": [
            "true"
        ],
        "Image": "busybox",
        "Volumes": null,
       ...

see sto question: http://stackoverflow.com/questions/35032368/docker-volumes-doesnt-exist-for-data-container-in-1-9-1

larrycai commented 8 years ago

In sto, VonC mentioned to use Mounts instead of .Config.Volumes, do you agree ?

niccokunzmann commented 8 years ago

Could you try the line on the command line, post the output and adapt it to the mounts? I do not know:

docker inspect --format="{{range \$k,\$v := .Config.Volumes}}{{println \$k}}{{end}}" my-data
larrycai commented 8 years ago

@niccokunzmann I made a simple PR based on your solution with new checking for Mounts, or you can redo your PR since it is too complex and modify too much.

larrycai commented 8 years ago

Don't have time and best solution to this fix (my PR has issues), any one to provide a simple PR for this ?