How to setup a server in the Cloud

This article sums up the steps to set up a new instance in the Cloud with basics stuff I need:

  • A volume to be mounted
  • Docker
  • Move Docker data to the volume mountpoint
  • Anything I encounter and need

NB: I’ve an account to the 3DS Outscale Cloud which looks like AWS one (but better :p)\ I used the web interface to perform Cloud operations where CLI tools are available.

Create the instance

Go to the Compute / Instance page, then choose to create an instance with following information:

  • A name (something one can use to undestand what’s the use of that instance)
  • Type: I used tinav4.c8r16p2 (8 CPU, 16GB of RAM and performance indix 2)
  • A keypair to be able to reach the instance with AK/SK

Other information are autmatically set. Note the External IP, which is the one used to reach the\ instance.

After any other action, install whatever we need on the instance, for example:

yum install vim  # Choice open to troll :p

Go to the Storage / Volumes page, then choose to create a volume with following information:

  • A name (Personally, I use names which relates to the name of the instance to be linked to the\ volume because I do not plan to move them)
  • A type: standard is enough
  • IOPS: let default (should be 150)
  • Size: 200GB should be enough (since we use Docker, which’s gourmand, be careful on the volume\ size)

Then choose “Attach” and select:

  • The instance to attach to (the one created at the previous step)
  • Device: The place where one will find the volume once mounted on the instance (/dev/xvdX with X\ is b or greater)

Then, connect to the instance with ssh outscale@$IP where the IP is the one of the instance\ above. Once on the instance, connect as root with sudo su.

Run the following commands:

# let be "/dev/xvdb" our volume
mkfs -t ext4 /dev/xvdb  # This will format the volume as ext4 type
mkdir /mnt/data  # Where to mount the volume
mount -t ext4 /dev/xvdb /mnt/data  # Perform the mount

Then, use your favorite CLI editor and add the following line to /etc/fstab:

/dev/xvdb /mnt/data ext4 defaults,nofail 0 0

This will enable automount of the volume on instance reboot.

Install Docker on the repository

As root:

yum install yum-utils  # Since we'll add a repository
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum install docker-ce docker-ce-cli containerd.io
usermod -aG docker outscale  # Make possible to run Docker as "outscale" user.
mkdir /mnt/data/docker
ln -s /mnt/data/docker /var/lib/docker  # Docker will use the volume to store its stuffs...
systemctl start docker  # Manually start Docker
systemctl enable docker  # Allow Docker to start on instance start up.

One can test Docker firstly with systemctl status docker as root, and with\ docker run hello-world as basic (outscale) user (to make sure that user is allowed to create\ container).