|
Hello everyone, today we have to look at how to use the Docker Machine deployment Swarm cluster. Docker Machine provides a standard Docker API support, so anything that can interact with Docker daemon tools can be used to Swarm (transparently) to amplify multiple hosts. Docker Docker Machine can be used to create a host PC, and the cloud data center. It is to create a server, and install Docker Docker set by the user to configure the client provides facilitation solutions. We can use any drive to deploy swarm cluster, and the cluster will swarm the use of TLS encryption has excellent security.
1. Install Docker Machine
Docker Machine on a variety of Linux systems are supported well. First, we need to download the latest version of the Docker Machine from Github. We use the curl command to download the first version Docker Machine ie 0.2.0.
64-bit operating systems:
# Curl -L https://github.com/docker/machine/releases/download/v0.2.0/docker-machine_linux-amd64> / usr / local / bin / docker-machine
32-bit operating systems:
# Curl -L https://github.com/docker/machine/releases/download/v0.2.0/docker-machine_linux-i386> / usr / local / bin / docker-machine
Downloaded the first version of the Docker Machine, we need permission to / usr / local / bin / directory docker-machine file to be modified. Command is as follows:
# Chmod + x / usr / local / bin / docker-machine
After doing the above things in the future, we want to ensure docker-machine has been installed correctly. How the inspections? Run docker-machine -v instructions that will be given docker-machine version of our installed on your system.
# Docker-machine -v
Installing Docker Machine
To make Docker command to run on our machines, you must also install the client on the machine Docker. Command is as follows.
# Curl -L https://get.docker.com/builds/linux/x86_64/docker-latest> / usr / local / bin / docker
# Chmod + x / usr / local / bin / docker
2. Create Machine
After the Docker Machine installed on our devices, we need to use the Docker Machine create a machine. In this article, we will be deployed on the Digital Ocean Platform. So we will use the "digitalocean" as its Driver API, then docker swarm run in them. The Droplet is set to Swarm master node, we need to create another Droplet, and set it to Swarm node agent.
Create machine commands are as follows:
# Docker-machine create --driver digitalocean --digitalocean-access-token < API-Token> linux-dev
Note: Suppose we want to create a machine named "linux-dev" of. The user is generated in the Digital Ocean Cloud Platform of Digital Ocean control panel keys. To get the key, we need to log in to our Digital Ocean Control Panel, then click on the API options, then click Generate New Token, a name, and then tick the Read and Write two options. Then we will get a very long hex keys, the grindstone. Use it to replace the one above command API-Token field.
Now, run the following command will Machine configuration variables loaded into the shell.
# Eval "$ (docker-machine env linux-dev)"
Docker Machine Digitalocean Cloud
Then, we use the following command to our machine marked ACTIVE.
# Docker-machine active linux-dev
Now, we check it (refer to machine) whether the order is marked ACTIVE "*".
# Docker-machine ls
Docker Machine Active List
3. Run Swarm Docker image
Now, we have created the machine after. We need to swarm docker up image deployment. The machine will run the docker mirrored and control Swarm master node and slave nodes. Use the following command to run the mirror:
# Docker run swarm create
Docker Machine Swarm Create
If you want to run swarm docker mirrors on 32-bit operating system. You need to log in to the SSH Droplet them.
# Docker-machine ssh
# Docker run swarm create
# Exit
4. Create a master node Swarm
After our swarm image which has been running in the machine, we will create a Swarm master node. Use the following statement to add a master node.
# Docker-machine create \
-d digitalocean \
--digitalocean-access-token < DIGITALOCEAN-TOKEN>
--swarm \
--swarm-master \
--swarm-discovery token: // < CLUSTER-ID> \
swarm-master
Docker Machine Swarm Master Create
5. Create Swarm from node
Now, we are going to create a swarm from the node, which will be connected with the Swarm master node. The following command will create a new named swarm-node of the droplet, which is connected to the master node Swarm. At this point, we have a two-node cluster of the swarm.
# Docker-machine create \
-d digitalocean \
--digitalocean-access-token < DIGITALOCEAN-TOKEN>
--swarm \
--swarm-discovery token: // < TOKEN-FROM-ABOVE> \
swarm-node
Docker Machine Swarm Nodes
6. The master node is connected with the Swarm
Now, we connect Swarm master node so that we can deploy Docker container between nodes in accordance with the needs and profile. Run the following command loads Machine profile Swarm master node to the environment.
# Eval "$ (docker-machine env --swarm swarm-master)"
Then, we will be able to run across the nodes we need a container. Here, we have to check if everything is normal. So, run docker info command to check Swarm cluster.
# Docker info
to sum up
We can create a Swarm Docker Machine clusters easily. This method has very high efficiency, because it greatly reduces the system administrator and user time-consuming. In this article, we take a drive Digital Ocean, through the creation of a master node and a slave node successfully deployed cluster. There are other similar drive VirtualBox, Google Cloud Computing, Amazon Web Service, Microsoft Azure and so on. These connections are encrypted via TLS, with high security. |
|
|
|