Docker Zookeeper
You can find the official Zookeeper docker image here:
Run a zookeeper server like this:
docker run --name server1 --restart always -d zookeeper
Connect from another containerized application:
docker run --name my-application --link server1:zookeeper -d my-application
Connect from the CLI client. This runs another zookeeper instance in a container but runs the cli in the foreground which is good for testing.
docker run -it --rm --link server1:zookeeper zookeeper zkCli.sh -server zookeeper
Configuration
Create a custom config here:
vi zoo.cfg
Mount the config file as a volume:
docker run --name server1 --restart always -d -v $(pwd)/zoo.cfg:/conf/zoo.cfg zookeeper
You could also just mount the config dir as a volume:
docker run --name server1 --restart always -d -v $(pwd)/conf:/conf zookeeper
You can also use environment variables instead of relying on the config file. I personally prefer to just use the config file.