• 欢迎订阅我的Youtube频道
  • 欢迎加入我的电报群

Use Azure file as docker volumn on Azure linux VM

软件开发 fennng 1年前 (2018-04-03) 614次浏览 0个评论
I have a website running in azure container instance. I noticed that container instance is not cheaper than a linux VM. I would like to migrate to linux VM.
The process is quite simple.
Firstly, you need to create a linux VM from azure portal.
Then follow this website to get docker.
https://docs.docker.com/install/linux/docker-ce/ubuntu/#install-docker-ce-1
Most important command is sudo apt-get install docker-ce
Now you have docker installed.  You can run wordpress in docker easily. But I would like to link my new wordpress docker container to my existing azure file.
To do this, we need to install a plugin to allow VM to connect to azure file.
//download docker volume driver
// Move it
sudo mv azurefile-dockervolumedriver /usr/bin/
// make it executable
chmod +x /usr/bin/azurefile-dockervolumedriver
// Download this zip to get the two files
// install unzip
sudo apt install unzip
// unzip the file
unzip v0.5.1.zip
// copy the default file to the right location
sudo cp azurefile-dockervolumedriver-0.5.1/contrib/init/systemd/azurefile-dockervolumedriver.default /etc/default/azurefile-dockervolumedriver
// edit it to match your storage account
sudo vi /etc/default/azurefile-dockervolumedriver

You can get your storage info from azure portal

// Copy service file to right location
sudo cp azurefile-dockervolumedriver-0.5.1/contrib/init/systemd/azurefile-dockervolumedriver.service /etc/systemd/system/azurefile-dockervolumedriver.service
// Start the service, you will need to enter password for following four commands
systemctl daemon-reload
systemctl enable azurefile-dockervolumedriver
systemctl start azurefile-dockervolumedriver
systemctl status azurefile-dockervolumedriver

Use following commands to test, if myvol exist, it will use it, otherwise, a new store created.
sudo docker volume create -d azurefile –name myvol -o share=myvol
sudo docker run -i -t -v myvol:/data busybox
// Start a new wordpress instance
sudo docker volume create -d azurefile –name vol -o share=existStorageName
sudo docker run -d –name wp -v vol:/var/www/html -p 80:80 wordpress
Open http port from azure portal for the VM
All good, you can stop your old container instance now, don’t forget to update your dns to point to the new server.
​​

Feng

峰享技术 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:Use Azure file as docker volumn on Azure linux VM
喜欢 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址