日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

docker三剑客之docker-machine

發布時間:2024/4/17 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 docker三剑客之docker-machine 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
#安裝docker-machine cupid@ubuntu:~$ pwd /home/cupid cupid@ubuntu:~$ ls Desktop docker-machine-Linux-x86_64 Documents Downloads examples.desktop Music Pictures Public Templates Videos cupid@ubuntu:~$ mv docker-machine-Linux-x86_64 docker-machine cupid@ubuntu:~$ chmod +x docker-machine cupid@ubuntu:~$ sudo scp docker-machine /usr/local/bin/docker-machine cupid@ubuntu:~$ docker-machine version #安裝成功 docker-machine version 0.12.2, build 9371605 ## cupid@ubuntu:~$ cd /etc/bash_completion.d/ cupid@ubuntu:/etc/bash_completion.d$ ls apport_completion git-prompt insserv desktop-file-validate grub libreoffice.sh cupid@ubuntu:/etc/bash_completion.d$ vi docker-machine-prompt.bash ~ ##添加被管理節點 1)生成ssh-key并拷貝到被管理節點 root@ubuntu:~# ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/root/.ssh/id_rsa): /root/.ssh/id_rsa already exists. Overwrite (y/n)? y Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_rsa. Your public key has been saved in /root/.ssh/id_rsa.pub. The key fingerprint is: SHA256:vleIKvWOKKZLtgNiZOe2z1U13xuuYLXKReYq1/Z/O74 root@ubuntu The key's randomart image is: +---[RSA 2048]----+ | | | | | o | | o . . o . | |o o So . = o | |o. o ..o . * o o| |+o. .. +. +.+ o | |o.+.o.o..o+.=o...| |o=..o+..o.o+..oEB| +----[SHA256]-----+ root@ubuntu:~# ssh-copy-id 192.168.142.169 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub" /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@192.168.142.169's password: Number of key(s) added: 1Now try logging into the machine, with: "ssh '192.168.142.169'" and check to make sure that only the key(s) you wanted were added.root@ubuntu:~# ssh-copy-id 192.168.142.170 /usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub" The authenticity of host '192.168.142.170 (192.168.142.170)' can't be established. ECDSA key fingerprint is SHA256:nMYNsS3zGCBuh8jVYGG4XRieWfH0SvvAMIhz2O+bZKc. Are you sure you want to continue connecting (yes/no)? yes /usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed /usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys root@192.168.142.170's password: Number of key(s) added: 1Now try logging into the machine, with: "ssh '192.168.142.170'" and check to make sure that only the key(s) you wanted were added. #無需輸入密碼可登陸169 root@ubuntu:~# ssh 192.168.142.169 Welcome to Ubuntu 16.04.2 LTS (GNU/Linux 4.10.0-28-generic x86_64)* Documentation: https://help.ubuntu.com* Management: https://landscape.canonical.com* Support: https://ubuntu.com/advantage52 packages can be updated. 1 update is a security update. 2)添加被管理節點 因為是虛擬機,指定普通操作系統即可 root@ubuntu:~# docker-machine create --driver generic --generic-ip-address=192.168.142.169 host1 Creating CA: /root/.docker/machine/certs/ca.pem Creating client certificate: /root/.docker/machine/certs/cert.pem Running pre-create checks... Creating machine... (host1) No SSH key specified. Assuming an existing key at the default location. 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 ubuntu(systemd)... Installing Docker... 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 host1 #查看添加的主機 root@ubuntu:~# docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS host1 - generic Running tcp://192.168.142.169:2376 v17.06.0-ce ~ ~ 3)如何管理節點的docker [root@host1:~]#echo $PS1 [\u@\h:\w$(__docker_machine_ps1)]\$ [root@host1:~]#docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS host1 - generic Running tcp://192.168.142.169:2376 v17.06.0-ce host2 - generic Running tcp://192.168.142.170:2376 v17.06.0-ce #查看連接到host1需要的環境變量 [root@host1:~]#docker-machine env host1 export DOCKER_TLS_VERIFY="1" export DOCKER_HOST="tcp://192.168.142.169:2376" export DOCKER_CERT_PATH="/root/.docker/machine/machines/host1" export DOCKER_MACHINE_NAME="host1" # Run this command to configure your shell: # eval $(docker-machine env host1) #查看連接到host2需要的環境變量 [root@host1:~]#docker-machine env host2 export DOCKER_TLS_VERIFY="1" export DOCKER_HOST="tcp://192.168.142.170:2376" export DOCKER_CERT_PATH="/root/.docker/machine/machines/host2" export DOCKER_MACHINE_NAME="host2" # Run this command to configure your shell: # eval $(docker-machine env host2) #eval此環境變量即可連接到host2的docker [root@host1:~]#eval $(docker-machine env host2)[root@host1:~ [host2]]#docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 87300fa502e3 busybox "sh" About an hour ago Exited (0) About an hour ago focused_cray aea28d5d7030 busybox "-it" About an hour ago Created keen_noether c9370139a79e httpd "httpd-foreground" 5 days ago Exited (255) 2 hours ago 80/tcp quirky_hypatia e5deab94f264 centos "/bin/bash -c 'whi..." 5 days ago Exited (255) 2 hours ago romantic_johnson d19d1c95874f registry:2 "/entrypoint.sh /e..." 5 days ago Exited (255) 2 hours ago 0.0.0.0:5000->5000/tcp hardcore_colden ~

?

轉載于:https://www.cnblogs.com/wanyp/p/7257457.html

總結

以上是生活随笔為你收集整理的docker三剑客之docker-machine的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。