I'm still quite a bit bummed about not being able to attend DockerCon this year. However, the news coming from DockerCon makes up for it in so many ways.
As a member of the Docker Captains programmed I was fortunate enough to preview 1.12 and am quite amazed of all the new features baked in.
What's new in Docker 1.12
- Multi-Host and Multi-Container Orchestration built-in
- Docker Service and Node added to Docker Engine
- Security is built into Swarm by default
- New File format - Distributed Application Bundle (DAB) making it easy to distribute multi-service application stacks between hosts.
Orchestration has become an integral component in the container ecosystem. Actually it so much a key component that Docker has taken the lead and built it directly into the Docker Engine! So what does this mean for our applications?
Starting with Docker 1.12 we now can deploy and manage applications on a Docker Swarm.
Open your CLI and run:
$ docker swarm init --listen-addr 0.0.0.0:2377
docker swarm init will activate your current Docker Node (Localhost) and promote it to become the Swarm Manager.
$docker swarm init --listen-addr 0.0.0.0:2377 Swarm initialized: current node (278hteadkjbqbbze4svd07wge) is now a manager.
Let's check the status of our Swarm.
$docker node ls ID NAME MEMBERSHIP STATUS AVAILABILITY MANAGER STATUS 278hteadkjbqbbze4svd07wge * moby Accepted Ready Active Leader
We now have a single node Swarm running on our local machine that quickly. Pat yourself on the back as previously this used to be quite some configuration and typing and now we has been achieved faster than you can finish this sentence.
Docker Service is similar to the Docker Run command. With Docker Service we can now build, distribute, load balance and replicate our service across our Docker Swarm.
Since we have a fresh Docker Swarm running waiting for something to do let's use the new docker service functionality and create a service and push it to our Swarm.
Let's create a service which Ping's our Localhost. We will create the service with only 1 instance (replicas) and afterwords scale our service.
First, create the ping service:
$ docker service create --replicas 1 --name ping alpine ping 0.0.0.0
This will now download the image and start the process on your Docker Swarm.
Check the status of our Ping job:
$ docker service ls ID NAME REPLICAS IMAGE COMMAND 9be0y9gn47o3 ping 1/1 alpine ping 0.0.0.0
Our service is now running and pinging our Localhost. If you want to see your container running you can still run a
$ docker ps to see the container which runs the service.
Docker Service Scale
Now that our service is running and successfully pinging Localhost let's scale the ping service. The next command will scale our service from 1 to 3 instances of our process and orchestrate them onto our Swarm.
Scale the ping service:
$ docker service update --replicas 3 ping ``` Let's check to see if the scaling worked. ``` $ docker service ls ID NAME REPLICAS IMAGE COMMAND 9be0y9gn47o3 ping 3/3 alpine ping 0.0.0.0 ``` ## Summary We've now successfully built a local Docker Swarm on our Docker for Mac/Windows machine, created a service, and scaled this service. With these new features built into the Docker machine it is even easier to deploy distributed, scalable apps across a hybrid or global infrastructure. Stay tuned as we provide more news from DockerCon. Also, I will take a deep dive of the Docker Service and how we can really use all the benefits combined with Docker Swarm.