Getting started with Docker and Glesys File Storage

You can use Glesys File Storage as a persistent storage solution in Docker.


Glesys's File Storage is a reliable and straightforward solution for storing persistent data in Docker. Because Docker volumes can easily use NFS when it’s installed on the Docker worker, you’re up and running in no time.

Preparation

Start by creating a virtual machine in Glesys Cloud and granting it access to the file storage. It’s essential that your virtual machine—where your Docker containers will run—can reach the storage volume. You don’t need to mount the file system on the server.

Installing the necessary packages

We assume that you are using Debian here.

Start by installing the package for NFS:

Command
sudo apt install nfs-common

Installing Docker

Next, you'll need to install Docker. To get the latest version, it's better to install Docker directly from Docker's own repository.

Run the following commands to add Docker's repository to your virtual machine:

Multiple commands
sudo apt update
sudo apt install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/debian/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

Then, copy and paste this long command:

Finally, install Docker by running:

Trying out an NFS volume in Docker

Create the volume. NfsVolume1 in the example is the volume's name. Also, replace fs-vdwx4.cloud.glesys.net with the URL to your File Storage instance.

Start a Docker container that utilizes the volume. The container is a simple Bash shell:

Now, while you're still running the container, create a file with some content:

Exit the container:

Let's re-run the container:

And check out the file you created earlier:

The output should be:

Exit the container again with exit.

Using NFS volumes in Docker Compose

Create the following docker-compose.yml file. Remember to replace fs-vdwx4.cloud.glesys.net with the URL to your File Storage instance. And set a real password for MYSQL_ROOT_PASSWORD.

Before we can start this compose project, we need to create the mysql-data directory in our File Storage. The easiest way to do this is to mount it on the server and create the directory (replace fs-vdwx4.cloud.glesys.net with the URL to your File Storage):

Now, you can bring up the Docker Compose project with MySQL:

Check out its log to make sure everything is working:

Last updated

Was this helpful?