The Gluster Blog

Gluster blog stories provide high-level spotlights on our users all over the world

Community Gluster Image on Docker

Gluster
2014-06-19

If you would like to try out gluster, a new CentOS based docker container is available on the docker hub at https://registry.hub.docker.com/u/gluster/gluster/. This image is very new, so do not use it for production environments. It is meant to be an early community version of gluster running within docker.

For correctness and performance reasons, we recommend running Gluster on an host-mounted XFS volume that resides on a separate device from the root filesystem. For this proof of concept, we use only a single node gluster daemon.

This community image was originally created by Frederick F. Kautz IV and Harshavardhana.

Usage

Prepare an XFS mount

The preferred method to use gluster is to mount an XFS partition on a separate device. If you want to test the image and do not have an XFS partition available on your system, you can create and mount one using the following commands:
dd if=/dev/zero of=/data/gluster.xfs bs=1M count=2048
mkfs.xfs -isize=512 /data/gluster.xfs
mkdir /mnt/gluster
mount -oloop,inode64,noatime /data/gluster.xfs /mnt/gluster

Run docker with the XFS mount

host # docker run --privileged -i -t -h gluster -v /mnt/gluster:/mnt/vault \
gluster/gluster:latest
container # df -h /mnt/vault
Filesystem      Size  Used Avail Use% Mounted on
/dev/loop4     2014M   45M  1969M   4% /mnt/vault

Access your new gluster volume from the host

Grab the ip address for the container
GLUSTER_CONTAINER_ID=$(docker ps | grep -i gluster | awk {'print $1'}
GLUSTER_IPADDR=$(docker inspect $GLUSTER_CONTAINER_ID | grep -i ipaddr | \
sed -e 's/\"//g' -e 's/\,//g' | awk {'print $2'})
Mount a container using the ip address provided in the above section.
mount -t glusterfs ${GLUSTER_IPADDR}:$VOLUME_NAME /mnt/gfs

Accessing your new gluster volume from a contaner

First, mount the volume to the host as shown in the previous section.
Second, mount the volume on container run
docker run -i -t -h gluster-client -v /mnt/gfs:/mnt/${VOLUME_NAME} gluster/gluster:latest
Note:
Docker drops CAP_SYS_ADMIN which prevents the user from mounting a container from within another container.

Shutting down and restarting gluster

Gluster stores metadata about the volume in /var/lib/glusterd and logs in /var/log/glusterfs. In order to preserve state, use docker commit before shutting down the cluster.
docker commit $GLUSTER_CONTAINER_ID mygluster:latest
docker kill $GLUSTER_CONTAINER_ID
To restart gluster, simply run your tagged gluster image.
docker run --privileged -i -t -h gluster -v /mnt/gluster:/mnt/vault mygluster:latest

Next Steps

We are investigating how to run gluster in a docker based multi-node environment. We will write a new blog post covering this topic soon. We are also investigating what changes are necessary to both gluster and docker to help support running gluster in docker.
If you are feeling adventurous, take a look at jpetazzo’s pipework project: https://github.com/jpetazzo/pipework.

BLOG

  • 06 Dec 2020
    Looking back at 2020 – with g...

    2020 has not been a year we would have been able to predict. With a worldwide pandemic and lives thrown out of gear, as we head into 2021, we are thankful that our community and project continued to receive new developers, users and make small gains. For that and a...

    Read more
  • 27 Apr 2020
    Update from the team

    It has been a while since we provided an update to the Gluster community. Across the world various nations, states and localities have put together sets of guidelines around shelter-in-place and quarantine. We request our community members to stay safe, to care for their loved ones, to continue to be...

    Read more
  • 03 Feb 2020
    Building a longer term focus for Gl...

    The initial rounds of conversation around the planning of content for release 8 has helped the project identify one key thing – the need to stagger out features and enhancements over multiple releases. Thus, while release 8 is unlikely to be feature heavy as previous releases, it will be the...

    Read more