Docker-machine (1) Installing the Management Docker host

Source: Internet
Author: User
Tags docker run

Description

Ubuntu System types

Test Docker, Docker-machine management operations user

192.168.1.73 Docker-machine Server-side

192.168.1.80 Docker Client

1sudo configuration:

Scope of execution: Docker-machine server-side, Docker client

sudo visudo

#追加1行, make sure the remote SSH command does not error

#sudo: No TTY present and no Askpass program specified

Defaults VISIBLEPW

#文件末尾追加 sudo no password required

Test all= (All) Nopasswd:all

Second, Docker-machine server-side configuration

2.1 Distributing the Public key

Generate private key, public key method self Google

SCP . SSH 192.168. 1.80:./SSH/

2.2 Download and install

Curl-l https://github.com/docker/machine/releases/download/v0.9.0-rc2/docker-machine-' uname-s '-' Uname-m ' >/tmp/docker-machinesudomv /tmp/docker-machine/usr/local/bin/sudo chmod A+x/usr/localbin/docker-machine

2.3 Creating a Docker host

[Email protected]:~$ docker-machine Create--driver generic--generic-ip-address=192.168.1.80--generic-SSH-key ~/.SSH/id_rsa--generic-SSH-user=test theRunning Pre-Create Checks ... Creating machine ... ( the) Importing SSH key ... Waiting forMachine to is running, this could take a few minutes ... Detecting operating system of created instance ... Waiting forSSH to be available ... Detecting the Provisioner ... Provisioning with Ubuntu (SYSTEMD) ... Installing Docker ... Copying certs to the Local machine directory ... Copying certs to the remote ... Setting Docker configuration on the remote daemon ... Checking connection to Docker ... Docker is up and running!your Docker Client to the Docker Engine running on this virtual machine, Run:docker-machineEnv  the

Docker-machine detailed commands See: https://docs.docker.com/machine/

Command analysis:

Create  #创建docker主机
--driver generic #驱动类型 generic supports Linux universal servers and supports a wide range of cloud hosts
--generic-ip-address=192.168.1.80 #指定主机
--generic-ssh-key ~/.ssh/id_rsa #指定私钥
--generic-ssh-user=test #指定用户
#主机名称

View the Docker hosts that have been created
ls NAME   ACTIVE   DRIVER    State     URL                       SWARM   DOCKER        ERRORS     *        generic   Running   tcp://192.168.1.73:2376           v17.06.0-ce        -        Generic   Running   tcp://192.168.1.80:2376           v17.06.0-ce  

Remotely execute Docker commands to create a Docker virtual machine

[Email protected]:~$ docker-machineSSH  theDockerPS-acontainer ID IMAGE COMMAND CREATED STATUS PORTS NAMES691BD1E50CD2 Hello-world"/hello"            2Days ago Exited (0)2Days ago Tender_banach[email protected]:~$ Docker-machineSSH  theDocker Run hello-World[email protected]:~$ Docker-machineSSH  theDockerPS-acontainer ID IMAGE COMMAND CREATED STATUS PORTS names68399de0b83b Hello-world"/hello"            5Seconds ago Exited (0)4seconds ago Thirsty_bohr691bd1e50cd2 Hello-world"/hello"            2Days ago Exited (0)2Days ago Tender_banach

You can also switch environment variables to achieve:

[Email protected]:~$ eval $ (docker-machineEnv  the) [email protected]:~$ Docker-machinelsNAME ACTIVE DRIVER State URL SWARM DOCKER ERRORS the-Generic Running TCP://192.168.1.73:2376 V17.06.0-ce the* Generic Running TCP://192.168.1.80:2376 V17.06.0-ce[Email protected]:~$ DockerPS-acontainer ID IMAGE COMMAND CREATED STATUS PORTS NAMES
68399de0b83b        hello-world         "/hello"            5 seconds ago       Exited (0) 4 seconds ago                       thirsty_ BOHR691BD1E50CD2        hello-world         "/hello"            2 days ago          Exited (0) 2 days ago                          Tender_banach

Docker-machine (1) Installing the Management Docker host

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.