TASK1. Docker Volume 플러그인 구성
Azure 로그인
PS C:\workspace> az login Note, we have launched a browser for you to login. For old experience with device code, use "az login --use-device-code" You have logged in. Now let us find all the subscriptions to which you have access... [ { "cloudName": "AzureCloud", "id": "24ebf866-0c20-435b-af0f-xxxxxxxxxx", "isDefault": true, "name": "Visual Studio Enterprise", "state": "Enabled", "tenantId": "075f7662-60f9-46bb-9158-xxxxxxxxx", "user": { "name": "sooabia22@sptek.co.kr", "type": "user" } } ] PS C:\workspace> PS C:\workspace> PS C:\workspace> az account show { "environmentName": "AzureCloud", "id": "24ebf866-0c20-435b-af0f-xxxxxxxxxx", "isDefault": true, "name": "Visual Studio Enterprise", "state": "Enabled", "tenantId": "075f7662-60f9-46bb-9158-xxxxxxxxxx", "user": { "name": "xxxxxxx@xxxxx.co.kr", "type": "user" } } PS C:\workspace> PS C:\workspace>
Docker 리소스 그룹 생성
PS C:\workspace> az group create --name "rg-DockerStorage" --location westus2 { "id": "/subscriptions/24ebf866-0c20-435b-af0f-xxxxxxxxxx/resourceGroups/rg-DockerStorage", "location": "westus2", "managedBy": null, "name": "rg-DockerStorage", "properties": { "provisioningState": "Succeeded" }, "tags": null, "type": null }
새 저장소 계정 생성
PS C:\workspace> az storage account create --location westus2 --name acstudy --resource-group "rg-DockerStorage" --sku Standard_LRS { "accessTier": null, "creationTime": "2019-04-08T08:03:37.865216+00:00", "customDomain": null, "enableAzureFilesAadIntegration": null, "enableHttpsTrafficOnly": false, "encryption": { "keySource": "Microsoft.Storage", "keyVaultProperties": null, "services": { "blob": { "enabled": true, "lastEnabledTime": "2019-04-08T08:03:37.974598+00:00" }, "file": { "enabled": true, "lastEnabledTime": "2019-04-08T08:03:37.974598+00:00" }, "queue": null, "table": null } }, "failoverInProgress": null, "geoReplicationStats": null, "id": "/subscriptions/24ebf866-0c20-435b-af0f-xxxxxxxx/resourceGroups/rg-DockerStorage/providers/Microsoft.Storage/storageAccounts/acstudy", "identity": null, "isHnsEnabled": null, "kind": "Storage", "lastGeoFailoverTime": null, "location": "westus2", "name": "acstudy", "networkRuleSet": { "bypass": "AzureServices", "defaultAction": "Allow", "ipRules": [], "virtualNetworkRules": [] }, "primaryEndpoints": { "blob": "https://acstudy.blob.core.windows.net/", "dfs": null, "file": "https://acstudy.file.core.windows.net/", "queue": "https://acstudy.queue.core.windows.net/", "table": "https://acstudy.table.core.windows.net/", "web": null }, "primaryLocation": "westus2", "provisioningState": "Succeeded", "resourceGroup": "rg-DockerStorage", "secondaryEndpoints": null, "secondaryLocation": null, "sku": { "capabilities": null, "kind": null, "locations": null, "name": "Standard_LRS", "resourceType": null, "restrictions": null, "tier": "Standard" }, "statusOfPrimary": "available", "statusOfSecondary": null, "tags": {}, "type": "Microsoft.Storage/storageAccounts" } PS C:\workspace>
Azure 저장소 계정 확인
PS C:\workspace> az storage account list --resource-group "rg-DockerStorage" --output table CreationTime EnableHttpsTrafficOnly Kind Location Name PrimaryLocation ProvisioningState ResourceGroup StatusOfPrimary -------------------------------- ------------------------ ------- ---------- ------- ----------------- ------------------- ---------------- ----------------- 2019-04-08T08:03:37.865216+00:00 False Storage westus2 acstudy westus2 Succeeded rg-DockerStorage available 2019-04-05T04:57:01.843056+00:00 False Storage westus2 sansesa westus2 Succeeded rg-DockerStorage available PS C:\workspace>
저장소 계정 KEY 목록 확인
PS C:\workspace> az storage account keys list --account-name acstudy --resource-group "rg-DockerStorage" --output table KeyName Permissions Value --------- ------------- ---------------------------------------------------------------------------------------- key1 Full bQpSz03Yq0as81yuO1Y4BE9KsYekC/KuDK3rW93EiMzHs++v6csK0/rLfiWMxH+ot3K8W6J9Cxxxxxxxxxxx== key2 Full lvExSn+rOHXZeK9WVRkw/GWeqg6VlE00UmHa8D50ZB0dVi///50AFEsNlTwznmq2kRDudgtkGEuvpxxxxxxxxxx== PS C:\workspace>
Docker machine 활성화
PS C:\workspace> docker-machine env azuredockervm | Invoke-Expression PS C:\workspace> docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS azuredockervm * azure Running tcp://13.77.178.238:2376 v18.09.4 localdockervm - hyperv Running tcp://[fe80::215:5dff:fe0b:7308]:2376 v18.09.4 PS C:\workspace> docker-machine ip azuredockervm 13.77.178.238 PS C:\workspace>
SSH 저장 KEY및 경로(SSHKeyPath) 확인
PS C:\workspace> docker-machine inspect azuredockervm { "ConfigVersion": 3, "Driver": { "IPAddress": "", "MachineName": "azuredockervm", "SSHUser": "peadmin", "SSHPort": 22, "SSHKeyPath": "C:\\Users\\Sanse\\.docker\\machine\\machines\\azuredockervm\\id_rsa", "StorePath": "C:\\Users\\Sanse\\.docker\\machine", "SwarmMaster": false, "SwarmHost": "tcp://0.0.0.0:3376", "SwarmDiscovery": "", "ClientID": "", "ClientSecret": "", "Environment": "AzurePublicCloud", "SubscriptionID": "24ebf866-0c20-435b-af0f-xxxxxxxxxxxx", "ResourceGroup": "rg-DockerMachine", "DockerPort": 2376, "Location": "westus2", "Size": "Standard_DS2_v2", "Image": "Canonical:UbuntuServer:16.04.0-Lts:latest", "VirtualNetwork": "docker-machine-vnet", "SubnetName": "docker-machine", "SubnetPrefix": "192.168.0.0/16", "AvailabilitySet": "docker-machine", "StorageType": "Standard_LRS", "OpenPorts": [ "80", "8080" ], "PrivateIPAddr": "", "UsePrivateIP": false, "NoPublicIP": false, "DNSLabel": "", "StaticPublicIP": true, "CustomDataFile": "" }, "DriverName": "azure", "HostOptions": { "Driver": "", "Memory": 0, "Disk": 0, "EngineOptions": { "ArbitraryFlags": [], "Dns": null, "GraphDir": "", "Env": [], "Ipv6": false, "InsecureRegistry": [], "Labels": [], "LogLevel": "", "StorageDriver": "", "SelinuxEnabled": false, "TlsVerify": true, "RegistryMirror": [], "InstallURL": "https://get.docker.com" }, "SwarmOptions": { "IsSwarm": false, "Address": "", "Discovery": "", "Agent": false, "Master": false, "Host": "tcp://0.0.0.0:3376", "Image": "swarm:latest", "Strategy": "spread", "Heartbeat": 0, "Overcommit": 0, "ArbitraryFlags": [], "ArbitraryJoinFlags": [], "Env": null, "IsExperimental": false }, "AuthOptions": { "CertDir": "C:\\Users\\Sanse\\.docker\\machine\\certs", "CaCertPath": "C:\\Users\\Sanse\\.docker\\machine\\certs\\ca.pem", "CaPrivateKeyPath": "C:\\Users\\Sanse\\.docker\\machine\\certs\\ca-key.pem", "CaCertRemotePath": "", "ServerCertPath": "C:\\Users\\Sanse\\.docker\\machine\\machines\\azuredockervm\\server.pem", "ServerKeyPath": "C:\\Users\\Sanse\\.docker\\machine\\machines\\azuredockervm\\server-key.pem", "ClientKeyPath": "C:\\Users\\Sanse\\.docker\\machine\\certs\\key.pem", "ServerCertRemotePath": "", "ServerKeyRemotePath": "", "ClientCertPath": "C:\\Users\\Sanse\\.docker\\machine\\certs\\cert.pem", "ServerCertSANs": [], "StorePath": "C:\\Users\\Sanse\\.docker\\machine\\machines\\azuredockervm" } }, "Name": "azuredockervm" } PS C:\workspace>
SecureCRT Public Key설정
SecureCRT 로 docker-machine 로그인
Azure File Docker 볼륨 드라이버 설정 파일 다운로드
azurefile-dockervolumedriver.default | azurefile-dockervolumedriver.service |
---|---|
# Environment file for azurefile-dockervolumedriver.service # # AF_OPTS=--debug # AZURE_STORAGE_BASE=core.windows.net AZURE_STORAGE_ACCOUNT=youraccount AZURE_STORAGE_ACCOUNT_KEY=yourkey | [Unit] Description=Azure File Service Docker Volume Driver Documentation=https://github.com/Azure/azurefile-dockervolumedriver/ Requires=docker.service After=nfs-utils.service Before=docker.service [Service] EnvironmentFile=/etc/default/azurefile-dockervolumedriver ExecStart=/usr/bin/azurefile-dockervolumedriver $AF_OPTS Restart=always StandardOutput=syslog [Install] WantedBy=multi-user.target |
peadmin@azuredockervm:~$ peadmin@azuredockervm:~$ sudo -s root@azuredockervm:~# root@azuredockervm:~# wget -O azurefile-dockervolumedriver.default https://raw.githubusercontent.com/Azure/azurefile-dockervolumedriver/master/contrib/init/systemd/azurefile-dockervolumedriver.default --2019-04-08 08:32:02-- https://raw.githubusercontent.com/Azure/azurefile-dockervolumedriver/master/contrib/init/systemd/azurefile-dockervolumedriver.default Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.52.133 Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.52.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 187 [text/plain] Saving to: 쁝zurefile-dockervolumedriver.default azurefile-dockervolume 100%[============================>] 187 --.-KB/s in 0s 2019-04-08 08:32:02 (36.4 MB/s) - 쁝zurefile-dockervolumedriver.defaultsaved [187/187] root@azuredockervm:~# wget -O azurefile-dockervolumedriver.service https://raw.githubusercontent.com/Azure/azurefile-dockervolumedriver/master/contrib/init/systemd/azurefile-dockervolumedriver.service --2019-04-08 08:32:11-- https://raw.githubusercontent.com/Azure/azurefile-dockervolumedriver/master/contrib/init/systemd/azurefile-dockervolumedriver.service Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.52.133 Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.52.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 399 [text/plain] Saving to: 쁝zurefile-dockervolumedriver.service azurefile-dockervolume 100%[============================>] 399 --.-KB/s in 0s 2019-04-08 08:32:11 (88.5 MB/s) - 쁝zurefile-dockervolumedriver.servicesaved [399/399] root@azuredockervm:~#
Azure File Docker 볼륨 드라이버 다운로드
root@azuredockervm:~# wget https://github.com/Azure/azurefile-dockervolumedriver/releases/download/v0.5.1/azurefile-dockervolumedriver --2019-04-08 09:06:35-- https://github.com/Azure/azurefile-dockervolumedriver/releases/download/v0.5.1/azurefile-dockervolumedriver Resolving github.com (github.com)... 192.30.255.113, 192.30.255.112 Connecting to github.com (github.com)|192.30.255.113|:443... connected. HTTP request sent, awaiting response... 302 Found Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/43052748/1ee7d1e6-7d81-11e6-8974-23a88ac83569?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190408%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190408T090635Z&X-Amz-Expires=300&X-Amz-Signature=11d90c98645bf649154024a58956ea65b3ee9a7ef5e15089300282d1ed8924f3&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dazurefile-dockervolumedriver&response-content-type=application%2Foctet-stream [following] --2019-04-08 09:06:35-- https://github-production-release-asset-2e65be.s3.amazonaws.com/43052748/1ee7d1e6-7d81-11e6-8974-23a88ac83569?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190408%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190408T090635Z&X-Amz-Expires=300&X-Amz-Signature=11d90c98645bf649154024a58956ea65b3ee9a7ef5e15089300282d1ed8924f3&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Dazurefile-dockervolumedriver&response-content-type=application%2Foctet-stream Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.98.19 Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.98.19|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 9102400 (8.7M) [application/octet-stream] Saving to: 쁝zurefile-dockervolumedriver azurefile-dockervolume 100%[============================>] 8.68M 12.2MB/s in 0.7s 2019-04-08 09:06:36 (12.2 MB/s) - 쁝zurefile-dockervolumedriversaved [9102400/9102400] root@azuredockervm:~#
Azure Docker Volume Driver 설정
root@azuredockervm:~# mv azurefile-dockervolumedriver /usr/bin/ root@azuredockervm:~# chmod +x /usr/bin/azurefile-dockervolumedriver root@azuredockervm:~# root@azuredockervm:~# root@azuredockervm:~# mv azurefile-dockervolumedriver.default /etc/default/azurefile-dockervolumedriver root@azuredockervm:~# root@azuredockervm:~# root@azuredockervm:~# vi /etc/default/azurefile-dockervolumedriver root@azuredockervm:~# cat /etc/default/azurefile-dockervolumedriver # Environment file for azurefile-dockervolumedriver.service # # AF_OPTS=--debug # AZURE_STORAGE_BASE=core.windows.net AZURE_STORAGE_ACCOUNT=acstudy AZURE_STORAGE_ACCOUNT_KEY=bQpSz03Yq0as81yuO1Y4BE9KsYekC/KuDK3rW93EiMzHs++v6csK0/rLfiWMxH+ot3K8W6J9Ct2HshtwHzhK8Q== root@azuredockervm:~# root@azuredockervm:~# mv azurefile-dockervolumedriver.service /etc/systemd/system/azurefile-dockervolumedriver.service root@azuredockervm:~# root@azuredockervm:~# systemctl daemon-reload root@azuredockervm:~# systemctl enable azurefile-dockervolumedriver Created symlink from /etc/systemd/system/multi-user.target.wants/azurefile-dockervolumedriver.service to /etc/systemd/system/azurefile-dockervolumedriver.service. root@azuredockervm:~# root@azuredockervm:~# root@azuredockervm:~# systemctl start azurefile-dockervolumedriver root@azuredockervm:~# systemctl status azurefile-dockervolumedriver [0m azurefile-dockervolumedriver.service - Azure File Service Docker Volume Driver Loaded: loaded (/etc/systemd/system/azurefile-dockervolumedriver.service; enabled; vendor Active: active (running) since Mon 2019-04-08 09:44:39 UTC; 7s ago Docs: https://github.com/Azure/azurefile-dockervolumedriver/ Main PID: 19921 (azurefile-docke) Tasks: 4 Memory: 1.0M CPU: 3ms CGroup: /system.slice/azurefile-dockervolumedriver.service 붴19921 /usr/bin/azurefile-dockervolumedriver Apr 08 09:44:39 azuredockervm systemd[1]: Started Azure File Service Docker Volume Driver. root@azuredockervm:~#
Azure File에 Docker Volume생성
root@azuredockervm:~# docker volume create -d azurefile --name myvol -o share=myvol myvol root@azuredockervm:~# docker volume ls DRIVER VOLUME NAME local 90ca61a3ab5b424f0592d8ea0f3f20ff5ab1bd9bb84da365ee99c5f633cc5819 local 454b4e2443b259c11fa11fd4404b86e54d324ad74448db93934c384d22e749b7 local ec08bef2a099f4e4b64b7f2e74d80fd34f5e286b65868e50aebfe3a8f2418a47 azurefile myvol root@azuredockervm:~# root@azuredockervm:~# root@azuredockervm:~#
Docker Volume을 사용하는 새 컨테이너 생성 및 샘플파일 생성
root@azuredockervm:~# docker run -it --name azurefile_con -v myvol:/data busybox Unable to find image 'busybox:latest' locally latest: Pulling from library/busybox fc1a6b909f82: Pull complete Digest: sha256:954e1f01e80ce09d0887ff6ea10b13a812cb01932a0781d6b0cc23f743a874fd Status: Downloaded newer image for busybox:latest / # cd /data/ /data # echo "Hello World!" >> azurefiledocker.txt /data #
Azure Portal에서 파일 확인
0 Comments