Joonas' Note

Joonas' Note

로컬에 도커 머신을 설치한 이야기 본문

개발/Docker

로컬에 도커 머신을 설치한 이야기

2018. 11. 14. 00:45 joonas

    도커 머신을 설정하기 위해서 윈도우에 도커를 설치했다. 도커 공식 문서를 봐도 레거시가 너무 많고 버전별 설치 문서가 여러개라 헷갈렸는데 여기가 가장 맞는 것 같다.

    참고로 다른 컴퓨터에서 시도했다가 Windows 10 Home Edition이라 실패했고, 이 컴퓨터는 Windows 10 Education Edition (64bit)라서 설치할 수 있었다.

    아주 예전에 다른 이유로 Hyper-V는 이미 활성화된 상태였고, VirtualBox도 깔려있었다. Docker for Windows 설치 후 별다른 설정은 건든 것 없이 바로 도커 머신에 도커 서버를 등록하려했다. 드라이버는 (도커 툴박스에 VirtualBox가 포함되어 있다길래) virtualbox로 설정했다.

    하지만,

    $ docker-machine create --driver virtualbox --virtualbox-no-vtx-check default
    Running pre-create checks...
    (default) Unable to get the local Boot2Docker ISO version:  Did not find prefix "-v" in version string
    (default) Default Boot2Docker ISO is out-of-date, downloading the latest release...
    (default) Latest release for github.com/boot2docker/boot2docker is v18.09.0
    (default) Downloading C:\Users\master\.docker\machine\cache\boot2docker.iso from https://github.com/boo
    t2docker/boot2docker/releases/download/v18.09.0/boot2docker.iso...
    (default) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
    Creating machine...
    (default) Unable to get the local Boot2Docker ISO version:  Did not find prefix "-v" in version string
    (default) Default Boot2Docker ISO is out-of-date, downloading the latest release...
    (default) Latest release for github.com/boot2docker/boot2docker is v18.09.0
    (default) Downloading C:\Users\master\.docker\machine\cache\boot2docker.iso from https://github.com/boo
    t2docker/boot2docker/releases/download/v18.09.0/boot2docker.iso...
    (default) 0%....10%....20%....30%....40%....50%....60%....70%....80%....90%....100%
    (default) Copying C:\Users\master\.docker\machine\cache\boot2docker.iso to C:\Users\master\.docker\mach
    ine\machines\default\boot2docker.iso...
    (default) Creating VirtualBox VM...
    (default) Creating SSH key...
    (default) Starting the VM...
    (default) Check network to re-create if needed...
    (default) Windows might ask for the permission to configure a dhcp server. Sometimes, such confirmation
     window is minimized in the taskbar.
    Error creating machine: Error in driver during machine creation: Unable to start the VM: C:\Program Fil
    es\Oracle\VirtualBox\VBoxManage.exe startvm default --type headless failed:
    VBoxManage.exe: error: Raw-mode is unavailable courtesy of Hyper-V. (VERR_SUPDRV_NO_RAW_MODE_HYPER_V_RO
    OT)
    VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole

    결과는 처참했다. 그리고 훨씬 다양한 오류들을 마주했었지만 이 글에는 적지 않겠다. 아무튼 구글링을 해보니 Hyper-V와 충돌해서 그런 것이라며 Hyper-V를 지우라는 글을 읽었다.

    음... Hyper-V가 성능이 더 좋다는 데, 그럼 드라이버를 Hyper-V로 설정해보자. 결과는?

    $ docker-machine create --driver hyperv default
    Running pre-create checks...
    Error with pre-create check: "no External vswitch found. A valid vswitch must be available
     for this command to run. Check https://docs.docker.com/machine/drivers/hyper-v/"

    한번에 성공했으면 글 안 적었다. 이쯤되면 그냥 되면 아쉬울 정도.

    External virtual switch가 없다는 메시지와 함께 친절한 링크를 알려주셨다. 그리고 문서대로 가상 스위치를 만들어서 다시 시도했더니 성공했다!

    $ docker-machine create --driver hyperv default
    Running pre-create checks...
    (default) Unable to get the local Boot2Docker ISO version:  Did not find prefix "-v" in version string
    (default) Default Boot2Docker ISO is out-of-date, downloading the latest release...
    ...(똑같은 내용이라 생략)...
    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: C:\Program Files\Docker\Docker\Resources\bin\docker-machine.exe env default

    $ docker-machine.exe ls
    NAME      ACTIVE   DRIVER   STATE     URL                      SWARM   DOCKER     ERRORS
    default   -        hyperv   Running   tcp://192.168.0.3:2376           v18.09.0

    default 도커 서버를 지운게 아니라 처음부터 없었다 ;;; 처음부터 있던 서버가 아니라 별도로 만든 이름만 같은 도커 서버지만, 차이는 없는 지 아직 별다른 문제는 없다.

    제어할 도커 서버도 변경했다.

    $ eval $(docker-machine.exe env default)
    $ docker-machine.exe ls
    NAME      ACTIVE   DRIVER   STATE     URL                      SWARM   DOCKER     ERRORS
    default   *        hyperv   Running   tcp://192.168.0.3:2376           v18.09.0

    - Windows 10 Education (64비트)
    - Intel i7-7700K CPU @ 4.20GHz (8 CPUs)
    - 16GB RAM
    - 쉘은 Git Bash를 사용했다.

    Comments