17.04.14 Doker-machine tool usage summary (1)

Reference resources:
https://github.com/docker/mac...
https://docs.docker.com/machi...
http://lizhenliang.blog.51cto...
https://www.oschina.net/news/...
http://www.csdn.net/article/2...

Summary

Official overview of three points:

  • Install and run Docker on Mac or Windows

  • Provision and manage multiple remote Docker hosts

  • Provision Swarm clusters
    If you are a user of windows and macos, you already have docker-machine by default. linux users mainly use it for cluster management, docker management and a series of other operating tools.

docker machine is a simplified command tool for docker installation, which responds to platform docker installation by simple commands, such as virtual box, microsoft azure. For example, if you have multiple operating systems, ubuntu windows centos macos, then I need to learn to install them step by step according to the official website documents. Different operating systems have different installation steps, so after machine, it links to the host through ssh. We only need a few simple commands. To allow the host to install docker, this is very convenient for the cluster.

In a nutshell, docker solves a few problems

  • Docker Machine simplifies the complexity of deployment. Docker hosts can be built with only one command, whether on a virtual machine or on a public cloud platform.

  • Docker Machine provides centralized management of multi-platform and multi-Docker hosts

  • Docker Machine makes it easy for applications to migrate from local to cloud. It only needs to modify environment variables to communicate with any Docker host to deploy applications.

Install docker-machine

Please refer to the installation process: https://github.com/docker/mac...
In the installation process, you may encounter the situation that curl can't download, so we can go to git to download and choose our own version of the operating system.

We can use windows to turn over the wall or use proxy to download the machine into the linux operating system.

Later found that the reason for the slow, the original...

After I climbed the wall or downloaded it with Thunderbolt

At this point, we can use the docker-machine command to view the tool's help information.

Additional (installing docker-machine bash auto-completion script)

  • Automatically complete commands

  • Display the active machine in the shell prompt

  • A function wrapper that adds docker-machine use subcommands to switch active computers

https://github.com/docker/mac...

Docker machine Operating Principle

Doker-machine is more convenient for cluster management. Just like your server administrator, it can manage a piece of docker host through docker-machine. In the process of using it, we can use virtual box to install multiple virtual machines to install docker. Ker, and use docker-machine to manage these machines

Command parsing

docker Host Using Docker Machine and Local Virtual Machine

https://docs.docker.com/machi...
If it's a linux user, we've made sure that the server contains  VirtualBox After the software is installed (if we don't have a virtual box installed, we use apt # install virtual box), we can install one provided by docker directly. Boot2Docker Boot2Docker is a lightweight Linux distribution dedicated to running Docker containers, which ensures that our local computer resources are wasted as little as possible by programs we don't need.
Docker-machine downloads boot2docker directly when creating a virtual host.

  • Preliminary Exploration of Running a Virtual Host Containing Doker
    If you encounter the following problems

rror with pre-create check: "Get https://github-
cloud.s3.amazonaws.com/releases/14930729/2a7d9b36-1aba-11e7-951b-a7c27f5bb4fd.iso?X-
Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-
Credential=AKIAISTNZFOVBIJMK3TQ%2F20170414%2Fus-east-1%2Fs3%2Faws4_request&X-
Amz-Date=20170414T013059Z&X-Amz-Expires=300&X-Amz-
Signature=b4fb1737c6bc10503dec6f45e0bf6de269336fdf1f939eca6657fa207cb4c87b&X-Amz-
SignedHeaders=host&actor_id=0&response-content-
disposition=attachment%3B%20filename%3Dboot2docker.iso&response-content-
type=application%2Foctet-stream: dial tcp 52.216.64.200:443: getsockopt: connection refused"

We can download the image manually and put it where docker-machine can find it.

To ensure you don't duplicate your work, download the latest version of boot2docker

root@ubuntu-docker:/home# docker-machine create -d virtualbox mh-keystore
Running pre-create checks...
Error with pre-create check: "This computer doesn't have VT-X/AMD-v enabled. Enabling it in the BIOS is mandatory"

My ubuntu-docker is an Ubuntu 16 operating system running in Vmware on the Windows 10 host. Here are some of the questions I asked about. The solution is to turn on the virtualization engine in vmware.
https://github.com/docker/mac...

Next, the test shows that the virtual box installation is successful if the following results occur

root@ubuntu-docker:~/.docker/machine/cache# docker-machine create -d virtualbox mh-keystore
Running pre-create checks...
Creating machine...
(mh-keystore) Copying /root/.docker/machine/cache/boot2docker.iso to /root/.docker/machine/machines/mh-keystore/boot2docker.iso...
(mh-keystore) Creating VirtualBox VM...
(mh-keystore) Creating SSH key...
(mh-keystore) Starting the VM...
(mh-keystore) Check network to re-create if needed...
(mh-keystore) Found a new host-only adapter: "vboxnet0"
(mh-keystore) Waiting for an IP...
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with boot2docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env mh-keystore

So we created a new environment with docker virtual hosts
I have to say that my environment is really wonderful (Windows 10 host > Vmware (Ubuntu Linux) > VirtualBox (boot2docker)

Detailed use of docker-machine

After we have built virtual-box and boot2docker for docker-machine, we have successfully run a virtual host operating system and built-in docker.

  • 1. View the booted machine

  • 2. View the environment on the host

root@ubuntu-docker:/# docker-machine env mh-keystore
export DOCKER_TLS_VERIFY="1"
export DOCKER_HOST="tcp://192.168.99.100:2376"
export DOCKER_CERT_PATH="/root/.docker/machine/machines/mh-keystore"
export DOCKER_MACHINE_NAME="mh-keystore"
# Run this command to configure your shell: 
# eval $(docker-machine env mh-keystore)
  • 3. Link to the host shell. If there is no error, the link is successful.

#eval "$(docker-machine env my-machine)"

  • 4. View the IP address of the host

 $ docker run -d -p 8000:80 nginx

Case study: Create a web server for nginx in my-host

Keywords: Linux Docker Ubuntu github Windows

Added by deed02392 on Tue, 09 Jul 2019 21:19:09 +0300