[Newbie alert!] How is Docker for Mac different from other dockers?

I am just starting with Docker for Mac and what i found out is that many docker images i pull from the Docker Hub don’t work straight away. My last example is sebp/elk, an apparently very popular ELK stack.
When you read the documentation everything is supposed to work, so you dive into the forums and what you find there is that “it doesn’t work because of the stupid way docker is implemented in Docker for Mac”.
What do they mean with that? What do we, Mac users, have to do to make Docker Hub images work on Docker for Mac?

I haven’t had much trouble?

To answer the subject question: there are two ways to run Docker for Mac, the eponymous application and using Docker Toolbox or Docker Machine. If you run the “native” Docker for Mac:

  • docker run -p publishes ports on the host’s localhost interface, but there is no way for containers to reach back to these (normal inter-container networking works fine)
  • docker run --net=host doesn’t make much externally visible at all.
  • There is an intermediate Linux VM, but it’s hard to get to, and if you need to make changes to it, it’s tricky (there are at least two readily Googleable solutions)
  • If you have a container that depends on being run --privileged to make changes to the host, it’s not obvious what host it is
  • docker run -v /host/dir:/container/dir works, but very slowly, and not for every host directory (/Users works, /var/private/... tends not to)

The Docker Toolbox/Docker Machine path, in contrast, is very explicit that it’s running a Linux VM; it’s usually at 192.168.99.100; and just so long as you accept that stuff is running “somewhere else” it works fine. (docker run --net=host is the VM’s host network, but with the VM being explicit, you expect that; docker-machine ssh will get you a shell on the VM; and so on.)

(The application I generally work on has somewhat more complicated networking requirements, including a Consul container that must run --net host, and because of this I haven’t actually run the “native” Docker for Mac in a while.)

(I can’t find the specific “everything is broken on Mac” comment you were referring to?)

If you’re just learning Docker, I will advise you that this is not a “best practices” image. When the documentation says “this image does three things and here’s how to turn them off selectively”, it’s a strong hint that this really wants to be three separate containers, maybe stitched together using Docker Compose.

1 Like