2

I have an Ubuntu Azure VM whith a data disk mount in the /datadrive. As the documentation of Azure said, I must to install applications in that directory.

Now, I want to install docker with apt-get command, but it install docker in the default directory that is /usr/bin/docker, but i want to install in /datadrive

Do you know how can I install it that directory?

pbalasimon
  • 61
  • 3
  • 6
  • I am not much familiar with Azure, but I don't think there would a requirement that applications be installed to `/datadrive`. Can you please share a link to the Azure documentation that you are following? – Amit Nov 28 '17 at 17:18
  • 1
    https://learn.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-manage-disks – pbalasimon Nov 29 '17 at 10:27

2 Answers2

1

Do you know how can I install it that directory?

If you want to install docker on that directory, we can follow this steps:

If you have not mount data directory to /datadrive, please follow this link to mount it.

After mount data disk to /datadrive, here are the steps:

1.Download the static binary:

wget https://download.docker.com/linux/static/stable/x86_64/docker-17.09.0-ce.tgz

2.Copy the package to /datadrive:

cp docker-17.09.0-ce.tgz /datadrive/

3.Extract the archive with tar:

tar xzvf docker-17.09.0-ce.tgz

4.Add symbolic link to /usr/bin/:

ln -s docker /datadrive/docker/docker
ln -s /datadrive/docker/docker docker
ln -s /datadrive/docker/docker-containerd docker-containerd
ln -s /datadrive/docker/docker-containerd-ctr docker-containerd-ctr
ln -s /datadrive/docker/docker-containerd-shim docker-containerd-shim
ln -s /datadrive/docker/dockerd dockerd
ln -s /datadrive/docker/docker-init docker-init
ln -s /datadrive/docker/docker-proxy docker-proxy
ln -s /datadrive/docker/docker-runc docker-runc

5.Backup /etc/fstab:

cp /etc/fstab /etc/fstab.$(date +%Y-%m-%d)

6.Use rsync to copy /var/lib/docker/ to /datadrive/data/:

rsync -aXS /var/lib/docker/. /datadrive/data/

7.Modify /etc/fstab:

vi /etc/fstab

Add this to fstab:

/datadrive/data /var/lib/docker none bind 0 0

8.Start docker:

dockerd &

9.Run docker on it:

docker run -it ubuntu bash

Then we can find this docker data store in /datadrive/data/

root@jasonvm:/# cd /datadrive/data/containers/
root@jasonvm:/datadrive/data/containers# ls
1ab8037833e769f0dce6dab84b4c0f1caf07a062247889cc713300331a04278a  5fb3f7ab070f500b3a6038533afd916e3b1c2a34df25f862ef346de75deb2161  bd257355898f26d5213e3378e53ab2dc382aabbb11d5e3069ac06c94070c3342
582be93064dd95e7088e26d35b7a265d82258c77be6b3711956d4beb936ffbc8  88163f6d30b974e43790f39f948b5c4a63b59ed0810ceb8155c3b03563853cef  fd97b5d9a2a6d38d5c008b4d4665fe619d9d1c9a3e1cb8af1e2ad385d3a8b97d
root@jasonvm:/datadrive/data/containers# 

In this way, we can install docker on /datadrive and store docker data in that disk.

As the documentation of Azure said, I must to install applications in that directory.

Yes, Azure recommend users to install applications to data disk, because in this way, when your VM crash, we can recreate Azure VM (OS disk) then mount the data disk to it.

Jason Ye
  • 13,710
  • 2
  • 16
  • 25
0

in that case you need to install docker as binaries, because apt-get stores in standard file structure.

ref : https://docs.docker.com/engine/installation/linux/docker-ce/binaries/#prerequisites for binaries

sanath meti
  • 5,179
  • 1
  • 21
  • 30