SvenDowideit / dockerfiles

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

Samba isn't working #1

Open lazywei opened 10 years ago

lazywei commented 10 years ago

When I use

docker run --rm -v $(which docker):/docker -v /run/docker.sock:/docker.sock svendowideit/samba MY_CONTAINER

I got

Cannot connect to the Docker daemon. Is 'docker -d' running on this host?

I also tried

docker run --rm -v $(which docker):/docker -v $(readlink -f /var/run/docker.sock):/docker.sock -e $DOCKER_HOST svendowideit/samba MY_CONTAINER

and

docker run --rm -v $(which docker):/docker -v $(readlink -f /var/run/docker.sock):/docker.sock -e DOCKER_HOST svendowideit/samba MY_CONTAINER

but all failed.

SvenDowideit commented 10 years ago

I'm going to have to debug this tomorrow, as I'm about to goto bed.

where are you running docker from? Cannot connect may well mean you need to set the DOCKER_HOST, but that assumes you're running the docker client on your OSX box.

(tell me more :) )

lazywei commented 10 years ago

Have a good night :-)

I run docker from my OSX (i.e. host computer)

$ echo $DOCKER_HOST
tcp://localhost:4243

and other docker commands work fine:

$ docker images
REPOSITORY           TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
svendowideit/samba   latest              8292b93ea1c7        9 days ago          303.4 MB
ubuntu               13.10               5e019ab7bf6d        2 weeks ago         180 MB
SvenDowideit commented 10 years ago

mmm, frustrating. it works for me on my test OSX box (the first version you tried)

lazywei commented 10 years ago

should i use docker version below 0.11.1?

so what is the correct way to run this? could you give me your steps, and i can try if i make any mistake?

thanks

— Regards, Chih-Wei

On Sun, May 18, 2014 at 12:50 PM, Sven Dowideit notifications@github.com wrote:

mmm, frustrating. it works for me on my test OSX box (the first version you tried)

Reply to this email directly or view it on GitHub: https://github.com/SvenDowideit/dockerfiles/issues/1#issuecomment-43431393

SvenDowideit commented 10 years ago

na, it was only one out of 3 of my 0.11.1 setups that was weird, and it came good after a reboot.

so, what I ran from my OSX terminal was:

export DOCKER_HOST=tcp://localhost:4243
docker run -v /data --name data busybox true
docker run -v $(which docker):/docker -v /var/run/docker.sock:/docker.sock svendowideit/samba data

and that resulted in a samba share that I could access from my OSX finder using the host only network on the boot2docker vm (in my case 192.168.59.103 (if you boot2docker ssh, you can run ip addr to see if that is the right ip address for eth1

lazywei commented 10 years ago

OK. So I tried boot2docker status, it gives me: [2014-05-18 14:27:43] boot2docker-vm is aborted. (I'm not sure what is the problem here?) I then stop & restart boot2docker, and try your steps:

$ docker run -v /data --name data busybox true
Unable to find image 'busybox' locally
Pulling repository busybox
2d8e5b282c81: Download complete
511136ea3c5a: Download complete
6c991eb93460: Download complete
9f4e93171ec5: Download complete
$ docker images
REPOSITORY           TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
svendowideit/samba   latest              8292b93ea1c7        11 days ago         303.4 MB
ubuntu               13.10               5e019ab7bf6d        3 weeks ago         180 MB
busybox              latest              2d8e5b282c81        3 weeks ago         2.489 MB
$ docker ps -a
CONTAINER ID        IMAGE                  COMMAND                CREATED             STATUS                     PORTS               NAMES
b35156b7b621        busybox:latest         true                   9 seconds ago       Exited (0) 7 seconds ago                       data
$ docker run -v $(which docker):/docker -v /var/run/docker.sock:/docker.sock svendowideit/samba data
Error: No such image or container: samba-server
SvenDowideit commented 10 years ago

aborted means that the vm is not running.

The last means that it worked. You should see a samba container using docker ps and then be able to connect to it.

I'll have to improve the output, but i've not yet worked out a good consistent way to tell the user what IP address to connect to (now that we have --net host that should be simpler.

lazywei commented 10 years ago

OK. I can see samba now, thank you! But how can I connect to it? And how to access the "shared folders"?

In your case, you use a container "data". So the samba will also sync the folder between my OSX and that "data" container, right? If I want to use this samba-server in development, say Rails, I can create a container for Rails, and use

$ docker run -v $(which docker):/docker -v /var/run/docker.sock:/docker.sock svendowideit/samba RAILS_CONTAINER

right?

SvenDowideit commented 10 years ago

You connect to it like you do any other network share - it is likely to be at \192.168.59.103\data - but I'll need to go see what you do in OSX

mbinette commented 10 years ago

I am doing the exact same thing but from a Windows machine. I believe you are also using Windows. I have a clean boot2docker VM running in VirtualBox using the boot2docker-cli tool. I created a home-vol as in your example using:

$ docker run -v /home --name home-vol busybox true

I then try to run

$ docker run --rm -v $(which docker):/docker -v $(readlink -f var/run/docker.sock):/docker.sock svendowideit/samba home-vol

But all I get is

Error: Could not create local directory '' for bind mount: mkdir : no such file or directory!

Is there something simple I'm doing wrong?

psykomo commented 10 years ago

@mbinette try this command:

docker run -v $(which docker):/docker -v /var/run/docker.sock:/docker.sock -e DOCKER_HOST svendowideit/samba home