Skip to content

Instantly share code, notes, and snippets.

@feliperoberto
Created October 16, 2015 17:41
Show Gist options
  • Save feliperoberto/5585c51e291a8d065b6d to your computer and use it in GitHub Desktop.
Save feliperoberto/5585c51e291a8d065b6d to your computer and use it in GitHub Desktop.
seaweeds on docker
master:
image: seaweedfs
command: "master"
ports:
- '9333:9333'
- '8080:8080'
extra_hosts:
- 'master:192.168.0.15'
slave:
image: seaweedfs
links:
- master:master
command: "volume -dir='/data' -max=5 -mserver='master:9333' -port=8082 -ip='master'"
ports:
- '8082:8082'
@feliperoberto
Copy link
Author

FROM cydev/go
RUN go get github.com/chrislusf/seaweedfs/go/weed
RUN mkdir /data
RUN chmod 0777 /data
EXPOSE 8080
EXPOSE 9333
VOLUME /data
ENTRYPOINT ["weed"]

@feliperoberto
Copy link
Author

I need to run everything in the docker way. Without expose any port, so it'll be more secure and restricted to linked containers.

@dnephin
Copy link

dnephin commented Oct 16, 2015

This works:

master:
  image: dnephin/seaweedfs                                                                                                                                                                                                                                                        
  command: master                                                                                                                                                                                                                                                                 

slave:                                                                                                                                                                                                                                                                            
  image: dnephin/seaweedfs                                                                                                                                                                                                                                                        
  links:                                                                                                                                                                                                                                                                          
    - master                                                                                                                                                                                                                                                                      
  entrypoint: "sh -c"                                                                                                                                                                                                                                                             
  command: ['weed volume -dir=/data -max=5  -mserver=master:9333 -ip="$$(hostname -i)"']  

If you're using docker-compose 1.4.2 or earlier, make it $(hostname -i) instead of $$(hostname -i)

I used the Dockerfile from the repo to build dnephin/seaweedfs.

Here's how it works:

  • change the entrypoint to sh so that we can run other commands as part of the commandline
  • by using ["..."] as the command, the entire thing is taken as a single paramter to bash -c

Another "nicer" way to do this might be to create a bash script as the entrypoint:

run_weed.sh

#!/bin/bash
set -e
export IP_ADDR="$(hostname -i)"
exec $(eval echo weed $@)

and change the ENTRYPOINT /run_weed.sh (don't forget to chmod +x run_weed.sh).

That way you'll be able to just specify the command as you would normally.

command: "volume  -dir=/data -max=5  -mserver=master:9333 -ip=$IP_ADDR"

@dnephin
Copy link

dnephin commented Oct 16, 2015

Are you planning on putting this up on a public repo somewhere? I'd like to show off this example.

If you aren't, do you mind if I create a sandbox-seaweedfs repo ?

@feliperoberto
Copy link
Author

Nice,
as soon as possible i'll try.
thank you for help me!

@feliperoberto
Copy link
Author

Sorry, for some reason I have not seen your last comment (about to turn it public).
Well, feel free to do it. In this way other people could be helped in the future.

@feliperoberto
Copy link
Author

Man, I run your example now. Work like a charm.
Very thank you!
If you make a PR let me know to give you an up vote!

@dnephin
Copy link

dnephin commented Oct 19, 2015

Cool, I'll do that sometime soon!

@feliperoberto
Copy link
Author

;)

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