<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                2021-11-14 周天 ## 因子 最近在整理博客內容,因為平時使用`docker`的時候,見到了三劍客中的`docker-machine`,也就開始使用了。雖然現在`docker-machine`已經被官方棄用,不再維護更新,但是個人覺得其隔離性還是很好用的。(`Docker Desktop` 是官方主要更新維護的項目) ![](https://img.kancloud.cn/60/7a/607a105f61aca6996d114b15665dd988_1994x500.png) ## 認識和基本使用 1. docker-machine 可以讓你管理多個docker主機,能讓你本地建立多個docker虛擬機,之前docker環境相互隔離。 2. 下載對應的二進制命令文件,加入到自己的命令庫,就算是安裝完成,刪除則算是卸載完成。 3. 將docker-machine命令取別名dm,熟練使用ls、stop、start、ssh等命令。 ![](https://img.kancloud.cn/9c/13/9c13d907e01f2139fc59aa3dce59a556_2214x904.png) 4. 可以在自己的機器上安裝多個docker-machine,一個做nginx的學習,一個做mysql的學習,相互之前不影響,然后利用vbox把端口上的服務映射出來。 ## 例子:將dm內的p映射出來瀏覽器訪問 1. 先創建一個test的隔離環境 ``` bash mango@mangodeMacBook-Pro ~ % dm create --driver virtualbox test Running pre-create checks... Creating machine... (test) Copying /Users/mango/.docker/machine/cache/boot2docker.iso to /Users/mango/.docker/machine/machines/test/boot2docker.iso... (test) Creating VirtualBox VM... (test) Creating SSH key... (test) Starting the VM... (test) Check network to re-create if needed... (test) 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: dm env test ``` 2. ssh到test的docker machine上,運行portainer容器 ``` bash docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer\_data:/data portainer/portainer ``` ``` bash mango@mangodeMacBook-Pro ~ % dm ssh test ( '>') /) TC (\ Core is distributed with ABSOLUTELY NO WARRANTY. (/-_--_-\) www.tinycorelinux.net docker@test:~$ docker run -d -p 8000:8000 -p 9000:9000 --name=portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer\_data:/data portainer/portainer Unable to find image 'portainer/portainer:latest' locally latest: Pulling from portainer/portainer 94cfa856b2b1: Pull complete 49d59ee0881a: Pull complete a2300fd28637: Pull complete Digest: sha256:fb45b43738646048a0a0cc74fcee2865b69efde857e710126084ee5de9be0f3f Status: Downloaded newer image for portainer/portainer:latest aa130cadc27a40a24867f7cf54a76674e9457686bc4b6d30884f160908d29871 docker@test:~$ docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES aa130cadc27a portainer/portainer "/portainer" 6 seconds ago Up 6 seconds 0.0.0.0:8000->8000/tcp, 0.0.0.0:9000->9000/tcp portainer ``` 3. 通過virtualbox的端口映射,將9000端口映射到宿主機 ![](https://img.kancloud.cn/46/d4/46d464a06e3e092d5375465242cafb47_2088x1004.png) 4. 通過瀏覽器訪問代理的端口,http://127.0.0.1:10001 ![](https://img.kancloud.cn/57/da/57dabd5b69d8d80628605ad47a4737e3_2368x1432.png) ![](https://img.kancloud.cn/fa/4c/fa4c47e4a9ee4aee38bd0fad870bc81a_3356x1332.png) ## docker-machine vs multipass 1. 面對的人員角度不同,`docker-machine`是面對`docker`容器環境的使用者,而`multipass`則是面對`ubuntu`操作系統環境的使用者。 2. 雖然都是借助虛擬機技術來得到VM環境,但范圍體積不一樣。 3. 都是通過建立不同虛擬機,來達到相互隔離的特性,通過網橋實現內部網絡連通。 ``` bash mango@mangodeMacBook-Pro ~ % multipass ls Name State IPv4 Image k3s Running 192.168.64.2 Ubuntu 20.04 LTS 10.42.0.0 10.42.0.1 node1 Running 192.168.64.3 Ubuntu 20.04 LTS 10.42.1.0 10.42.1.1 rancher Running 192.168.64.4 Ubuntu 20.04 LTS mango@mangodeMacBook-Pro ~ % multipass shell rancher Welcome to Ubuntu 20.04.3 LTS (GNU/Linux 5.4.0-90-generic x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Sun Nov 14 22:26:19 CST 2021 System load: 0.7 Processes: 115 Usage of /: 27.6% of 4.67GB Users logged in: 0 Memory usage: 19% IPv4 address for enp0s2: 192.168.64.4 Swap usage: 0% 1 update can be applied immediately. To see these additional updates run: apt list --upgradable Last login: Sun Nov 14 22:25:51 2021 from 192.168.64.1 To run a command as administrator (user "root"), use "sudo <command>". See "man sudo_root" for details. ubuntu@rancher:~$ ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看