Search code examples
dockerapache-kafkavirtual-machinevirtualboxapache-zookeeper

Kafka docker container cannot run in virtual machine


I'm trying to run kafka docker image inside my VirtualBox. I firstly run zookeeper server by:

 docker run -d -p 2181:2181 --name zookeeper jplock/zookeeper

After that, I run kafka which is linked to that zookeeper server:

docker run -d --name kafka --link zookeeper:zookeeper ches/kafka

When I check "docker ps -a", only zookeeper is running and kafka is not (the status of kafka is always "Exited".

docker ps -a

However, when I do those things above outside VM, which is local machine, everything work just fine. What am I missing here?

Update: I just run the "docker logs kafka" and I got this:

docker logs kafka


Solution

  • I have figured out that VM did not have enough memory to allocate for kafka server. I got it from the last 3 bottom lines of the second picture above. And the solution is quite easy, I just need to assign bigger memory to VM in vagrantfile, previously it was 1024. And now:

    config.vm.provider "virtualbox" do |vm|
        vm.memory = 2048
        vm.cpus = 2