分享 How to connect Docker to CoreOS in Veertu

mimosa · 2017年01月12日 · 最后由 luikore 回复于 2017年01月12日 · 2038 次阅读

Why CoreOS?

CoreOS has become the preferred distro for Docker. You can download the Stable ISO

Why Veertu?

Like xhyve, Veertu takes advantage of the Hypervisor.framework that was introduced in OS X 10.10, which brings Type 1 hypervisor technology (direct, host-level access to hardware) to OS X. You can download it in the CloudFront

  1. Start the CoreOS image.

    • Set a password for user core
    core@localhost ~ $ sudo passwd core
    
  2. Get the ip address

    core@localhost ~ $ ip route
    default via 192.168.64.1 dev ens3  proto dhcp  src 192.168.64.X  metric 1024 
    172.17.0.0/16 dev docker0  proto kernel  scope link  src 172.17.0.1 
    192.168.64.0/24 dev ens3  proto kernel  scope link  src 192.168.64.X 
    192.168.64.1 dev ens3  proto dhcp  scope link  src 192.168.64.X  metric 1024
    
  3. Ssh into CoreOS

    ssh [email protected] -q -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
    
  4. Install CoreOS

    • Get your public SSH key

      cat ~/.ssh/id_rsa.pub
      
    • Generate a crypted password

      openssl passwd -1
      
    • Create a cloud-config.yml file to upgrade CoreOS, add your ssh key and open the docker socket when CoreOS starts:

      core@localhost ~ $ vi cloud-config.yml
      
      #cloud-config
      
      users:
        - name: core
          passwd: # paste your a crypted string to here
          groups:
            - sudo
            - docker
          # include one or more SSH public keys
          ssh-authorized-keys:
            - # paste your a public SSH key to here
      
      coreos:
        units:
          - name: docker-tcp.socket
            command: start
            runtime: no
            content: |
              [Unit]
              Description=Docker Socket for the API
              [Socket]
              ListenStream=2375
              Service=docker.service
              BindIPv6Only=both
              [Install]
              WantedBy=sockets.target
      
          - name: docker.service
            command: start
      
    • Install the CoreOS to /dev/sda with our cloud config:

      core@localhost ~ $ sudo coreos-install -d /dev/sda -c cloud-config.yml
      core@localhost ~ $ sudo reboot
      
  5. Usage and check

    • Set the docker host

      export DOCKER_HOST=tcp://192.168.64.X:2375
      
    • Check if it works

      docker info
      
  6. Sharing folder on your Mac

    • Install Add-ons.

      brew install ssh-copy-id osxfuse sshfs
      
    • Auto Login without a password.

      ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected] -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
      
    • Mount remote file systems over ssh.

      id -P <username>
      <username>:********:<uid>:<gid>::0:0:Mimosa:/Users/mimosa:/usr/local/bin/fish
      
      mkdir -p ~/Documents/veertu
      sudo sshfs -o allow_other,defer_permissions,reconnect,uid=<uid>,gid=<gid>,volname=veertu [email protected]:./ ~/Documents/veertu
      

这是个在 Mac 上用 Docker 的方案

台式机或者虚拟机 linux, 在 Mac 上通过 Veertu 远程执行各种 docker 命令,然后目录通过 sshfs/osxfuse 挂载到 Mac 上

看起来有点复杂,但其实比官方的 Docker for Mac 坑少...

需要 登录 后方可回复, 如果你还没有账号请 注册新账号