-
-
Save feliperoberto/5585c51e291a8d065b6d to your computer and use it in GitHub Desktop.
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' |
I need to run everything in the docker way. Without expose any port, so it'll be more secure and restricted to linked containers.
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 tobash -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"
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 ?
Nice,
as soon as possible i'll try.
thank you for help me!
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.
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!
Cool, I'll do that sometime soon!
;)
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"]