Get started with Docker for Mac Estimated reading time: 16 minutes Docker is a full development platform for creating containerized apps, and Docker for Mac is the best way to get started with Docker on a Mac.
If you’re running an edge version of Docker on your desktop (Docker for Mac or Docker for Windows Desktop), you can now stand up a single-node Kubernetes cluster with the click of a button. While I’m not a developer, I think this is great news for the millions of developers who have already been using Docker on their Macbook or Windows laptop because they now have a fully compliant Kubernetes cluster at their fingertips without installing any other tools.
Developers using Docker to build containerized applications often build Docker Compose files to deploy them. With the integration of Kubernetes into the Docker product line, some developers may want to leverage their existing Compose files but deploy these applications in Kubernetes.
With Docker on the desktop (as well as Docker Enterprise Edition) you can use Docker compose to directly deploy an application onto a Kubernetes cluster.
Here’s how it works:
Let’s assume I have a simple Docker compose file like the one below that describes a three tier app: a web front end, a worker process (
words) and a database.
Notice that our web front end is set to route traffic from port 80 on the host to port 80 on the service (and subsequently the underlying containers). Also, our words service is going to launch with 5 replicas.
I’m using Docker for Mac, and Kubernetes is set as my default orchestrator. To deploy this application I simply use docker stack deploy providing the name of our compose file (words.yaml) and the name of the stack (words). What’s really cool is that this would be the exact same command you would use with Docker Swarm:
Install Docker For Mac
Under the covers the compose file has created a set of deployments, pods, and services which can be viewed using kubectl.
If you look at the list of services you might notice something that seems a bit odd at first glance. There are services for both web and web-published. The web service allows for intra-application communication, whereas the web-publishedservice (which is a load balancer backed by vpnkit in Docker for Mac) exposes our web front end out to the rest of the world.
Access Docker Container
So if we visit http://localhost:80 we can see the application running. You can actually see the whole process in this video that Eltonrecorded.
Now if we wanted to remove the service you might think you would remove the deployments using kubectl (I know I did). But what you actually do is use docker stack rm and that will remove all the components created when we brought the stack up.
Docker Container Mac Address
And, to me, the cool thing is that this same process can be used with Docker EE – I simply take my Compose file and deploy it directly in the UI of Docker Enterprise Edition (EE) – but that’s another post.
Want to try it for yourself? Grab Docker for Mac or Docker for Windows, but be sure to check out the documentation (Mac and Windows) for more info.
Docker Container Tutorial
- Sign-up to download the Docker EE beta with Kubernetes ortry it in our labs
- Watch our DockerCon Europe 2017 Kubernetes Announcement
- Register for DockerCon 2018