Azure 가상 시스템에 docker 설치

7886 단어 DockerAzure

입문


다음은 Microsoft Azure 가상 시스템에서 docker 실행 환경을 설정하는 절차를 소개합니다.
일반적으로, 당신은 Azure의 관리 포털에서 Linux 가상 머신을 만들고 docker를 설정할 수 있습니다
이번에는 Azure의 명령행 인터페이스Xplat-CLI를 사용합니다.
Xplat-CLI에서
  • VM 생성
  • VM에 docker 설정
  • VM 노드 설정(docker 포트 열기)
  • 원격 연결을 위한 인증서 설정
  • 에서 기술한 장면은 다음과 같은 절차를 이용하여 명세표를 작성하여 개념 디자인에서 체량의 부피를 분석하도록 한다.

    사전 준비


    icrosoft Azure를 사용하려면 다음 두 가지를 참조하십시오.
  • Microsoft 계정
  • Azure 예약도 있음무료 평가판
  • 클라이언트 환경(CentOS7)


    클라이언트 환경에 xplat-cli와docker를 설치합니다.

    1. xplat-cli


    xplat-cli는 node입니다.js로 동작을 하기 때문에 우선 node.js에서 가져옵니다.
    CentOS7에서, epel에서 node.안에 js가 있어요.

    yum에 epel 추가

    # yum install epel-release
    

    yum에 nodejs,npm 설치

    # yum install nodejs npm
    

    npm에 azure-cli 설치

    # npm install -g azure-cli
    
    현재 사용 가능azure 명령
    # azure -v
    0.8.10
    
    Azure 가입에 연결하려면 게시 프로필(.publishsettings 파일)을 다운로드합니다.
    $ azure account download
    info:    Executing command account download
    info:    Launching browser to http://go.microsoft.com/fwlink/?LinkId=*****
    help:    Save the downloaded file, then execute the command
    help:      account import <file>
    info:    account download command OK
    
    브라우저에서 표시되는 링크에 액세스하여 게시 구성 파일을 다운로드할 수 있습니다.
    다음에 다운로드한 발행 설정 파일을 가져옵니다.
    $ azure account import path_to_*******-credentials.publishsettings 
    info:    Executing command account import
    info:    account import command OK
    $ 
    
    다음 명령을 통해 가입을 표시하면 됩니다.
    $ azure account list
    info:    Executing command account list
    data:    Name                 Id                                    Current
    data:    -------------------  ------------------------------------  -------
    data:    *******************  ************************************  true   
    info:    account list command OK
    $ 
    

    2.docker(클라이언트)


    이번 목적은 Azure에서docker 환경을 만드는 것입니다. 원래 클라이언트 환경에서docker가 필요하지 않지만 클라이언트에docker 명령이 있으면 Azure에서docker를 원격으로 조작할 수 있습니다. 편리하기 때문에 먼저 가져옵니다.

    yum에 docker 설치


    기본적으로 CentOS7은 Extras 저장소에 docker를 포함합니다.
    # yum install docker
    # docker -v
    Docker version 0.11.1-dev, build 02d20af/0.11.1
    

    Azure에서 Docker 배포용 가상 머신 만들기


    여기서부터 드디어 Azure에 Docker 환경을 만듭니다.
    그럼에도 불구하고 집행된 명령은 하나azure vm docker create뿐이다.
    다음과 같은 다양한 옵션을 지정할 수 있습니다.
    $ azure help vm docker create
    info:    Executing command help
    help:    Create a VM
    help:    
    help:    Usage: vm docker create [options] <dns-name> <image> <user-name> [password]
    help:    
    help:    Options:
    help:      -h, --help                             output usage information
    help:      -v, --verbose                          use verbose output
    help:      --json                                 use json output
    help:      -p, --docker-port [port]               Port to use for docker [4243]
    help:      -C, --docker-cert-dir [dir]            Directory containing docker certs [.docker/]
    help:      -c, --connect                          connect to existing VMs
    help:      -l, --location <name>                  the location
    help:      -a, --affinity-group <name>            the affinity group
    help:      -u, --blob-url <url>                   the blob url for OS disk
    help:      -z, --vm-size <size>                   the virtual machine size [small]
    help:          extrasmall, small, medium, large, extralarge, a5, a6, a7, a8, a9
    help:      -n, --vm-name <name>                   the virtual machine name
    help:      -e, --ssh [port]                       the ssh port to enable [22]
    help:      -t, --ssh-cert <pem-file|fingerprint>  the SSH certificate
    help:      -P, --no-ssh-password                  indicates that the password should be removed when using --ssh-cert
    help:      -w, --virtual-network-name <name>      the virtual network name
    help:      -b, --subnet-names <list>              the comma-delimited subnet names
    help:      -S, --static-ip <ip-address>           the static IP address assigned to the virtual machine
    help:      -R, --reserved-ip <name>               the name of the reserved IP address assigned to the virtual machine
    help:      -A, --availability-set <name>          the name of availability set to create or use
    help:      -s, --subscription <id>                the subscription id
    help:      -d, --custom-data <custom-data-file>   CustomData file
    $ 
    
    최소한 결정해야 할 항목은 다음과 같은 6개다.
    항목 설정
    값 지정
    FQDN
    {hostname}.cloudapp.net
    함부로 끼지 않는 호스트 이름을 지어드릴게요.
    위치
    Japan East
    근처 DC 선택
    VM 크기
    ExtraSmall
    시험이라서 제일 작아요.
    OS
    Ubuntu 14.04 LTS 64bit
    docker를 지원하는 운영체제 선택
    VM 이미지
    b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-14_04-LTS-amd64-server-20140724-en-us-30GB
    azure vm image list에서 가상 시스템 이미지 이름 찾기
    계정
    azureuser
    VM 로그인 계정

    가상 머신 만들기


    위에서 정한 설정값에 따라 실행azure vm docker create.
    $ azure vm docker create ¥
       {hostname} ¥
       --location "Japan East" ¥
       --vm-size ExtraSmall ¥
       b39f27a8b8c64d52b05eac6a62ebad85__Ubuntu-14_04-LTS-amd64-server-20140724-en-us-30GB ¥
       azureuser
    
    단, 약 5분 후에 Docker가 설치한 가상 머신이 배치되고 액세스 가능한 상태가 됩니다.
    참고로 Docker에 연결하는 인증서와 단점은 자동으로 설정됩니다.

    인증서


    인증서와 키는 클라이언트 홈페이지의 .docker 디렉터리에 저장됩니다.
    $ ls ~/.docker
    ca-key.pem  ca.pem  cert.pem  client.csr  extfile.cnf  key.pem  server-cert.pem  server-key.pem  server.csr
    $ 
    

    끝점


    가상 기기의 단점은 docker의 사용 포트 4243/tcp로 자동으로 설정됩니다.

    연결 테스트


    docker 명령을 사용하여 Azure의 docker에 연결하십시오.--tls 에서 암호화 통신에 사용되는 FQDN: 4243을 잊지 않고 가상 머신을 지정합니다.
    $ docker --tls -H=tcp://{hostname}.cloudapp.net:4243 version
    Client version: 0.11.1-dev
    Client API version: 1.12
    Go version (client): go1.2
    Git commit (client): 02d20af/0.11.1
    Server version: 1.3.0
    Server API version: 1.15
    Go version (server): go1.3.3
    Git commit (server): c78088f
    $ 
    
    그 다음은 일반적인 도커의 사용 방법과 같다.
    $ docker --tls -H=tcp://{hostname}:4243 pull centos:latest
    centos:latest: The image you are pulling has been verified
    511136ea3c5a: Pull complete 
    5b12ef8fd570: Pull complete 
    87e5b6b3ccc1: Pull complete 
    Status: Downloaded newer image for centos:latest
    $
    $ docker --tls -H=tcp://{hostname}.cloudapp.net:4243 images
    REPOSITORY          TAG                 IMAGE ID            CREATED             VIRTUAL SIZE
    centos              latest              87e5b6b3ccc1        2 weeks ago         224 B
    $
    $ docker --tls -H=tcp://{hostname}.cloudapp.net:4243 run -it centos /bin/bash
    bash-4.2# cat /etc/redhat-release 
    CentOS Linux release 7.0.1406 (Core) 
    bash-4.2# uname -a
    Linux 9c86914f674c 3.13.0-32-generic #57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
    bash-4.2# 
    
    Enjoy your docker life !

    끝내다


    최근 마이크로소프트와 Docker의 활동이 갈수록 활발해지고 있다.
    2014/10/15 양사발표하다에 따라 Docker Engine for Windows Server를 개발 중이며, 차세대 Windows 서버는 Windows의 컨테이너 가상화를 실현할 수 있습니다.
    Docker에 따라 Linux에서는 당연한 컨테이너 기술인데 Windows에서도 사용할 수 있다면 산기슭이 확 넓어지고 눈도 떨어질 수 없다.

    좋은 웹페이지 즐겨찾기