Creating a Docker Volume for Gogs and PostgreSQL Using NFS

Abhay DandgeAbhay Dandge
2 min read

Docker volumes are a crucial part of managing data in Docker containers, allowing for persistent storage that can be shared among multiple containers. One of the robust options for Docker volumes is using Network File System (NFS), which allows for network-based file sharing. This article will guide you through the process of creating Docker volumes for Gogs (a self-hosted Git service) and PostgreSQL using NFS.

Part III: Storage, the Docker Way

Prerequisites

  1. NFS Server: Ensure you have an NFS server set up and running.

  2. Docker: Install Docker on your host machine.

  3. Basic knowledge: Familiarity with Docker, Docker Compose, and basic NFS concepts.

To create a Docker volume for both Gogs and PostgreSQL using NFS, we need to set up an NFS server and then mount the NFS volume into your Docker containers.

1. Set Up NFS Server

First, we need to have an NFS server running and accessible from your Docker host.

Installation guide - https://ubuntu.com/server/docs/network-file-system-nfs

  • Install ssh-server on host

apt install nfs-server -y

  • Edit /etc/exports

\>Make dir for NFS

\>Refresh /etc/exports

2. Create Docker Volume

Now, on Docker host machine, create a Docker volume that mounts the NFS share:

3. Create a docker network

4. Start PostgreSQL Container with NFS Volume

Start the PostgreSQL container, mounting the NFS volume for data persistence:

5. Start Gogs Container with NFS Volume

Start the Gogs container, also mounting the NFS volume for its data:

6. Access port 3000 for interface

7. Check NFS server Dir for data

By following these steps, you can effectively create and use a Docker volume for both Gogs and PostgreSQL, leveraging NFS for data persistence across containers.

Conclusion

By following these steps, you can set up persistent storage for Gogs and PostgreSQL using NFS with Docker volumes. This setup provides a scalable and robust solution for managing data in a Dockerized environment. With the flexibility of NFS, you can easily expand and manage storage across different servers, ensuring your data is always available and secure.


Linkdin

2
Subscribe to my newsletter

Read articles from Abhay Dandge directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Abhay Dandge
Abhay Dandge

Hello, I'm Abhay, a DevOps Engineer passionate about optimizing operations through automation, continuous integration, and deployment. Over the past year, I've sharpened my skills in the fast-paced world of DevOps and Cloud Computing. My journey has been defined by hands-on experience and a commitment to exploring the latest technologies. ╭━━━╮╱╱╱╱╱╭━━━╮ ╰╮╭╮┃╱╱╱╱╱┃╭━╮┃ ╱┃┃┃┣━━┳╮╭┫┃╱┃┣━━┳━━╮ ╱┃┃┃┃┃━┫╰╯┃┃╱┃┃╭╮┃━━┫ ╭╯╰╯┃┃━╋╮╭┫╰━╯┃╰╯┣━━┃ ╰━━━┻━━╯╰╯╰━━━┫╭━┻━━╯ ╱╱╱╱╱╱╱╱╱╱╱╱╱╱┃┃ ╱╱╱╱╱╱╱╱╱╱╱╱╱╱╰╯⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀ In my tech toolkit, I’ve got the skills to make things run smoother: containerization, cloud platforms, and flawless CI/CD pipelines. My goal? To supercharge software delivery for organizations, making it faster and more efficient, all while keeping things top-notch and rock-solid. Let’s keep it cool and reliable! 🅃🄴🄲🄷 🅂🅃🄰🄲🄺 🔲 Cᴏɴᴛᴀɪɴᴇʀɪᴢᴀᴛɪᴏɴ -: Dᴏᴄᴋᴇʀ | Pᴏᴅᴍᴀɴ | Bᴜɪʟᴅᴀʜ | CᴏɴᴛᴀɪɴᴇʀD 🔲 Cᴏɴᴛᴀɪɴᴇʀ Oʀᴄʜᴇsᴛʀᴀᴛɪᴏɴ -: Kᴜʙᴇʀɴᴇᴛᴇs | Dᴏᴄᴋᴇʀ Sᴡᴀʀᴍ 🔲 Cʟᴏᴜᴅ Pʟᴀᴛғᴏʀᴍs -: AWS 🔲 Aᴜᴛᴏᴍᴀᴛɪᴏɴ ᴀɴᴅ Sᴄʀɪᴘᴛɪɴɢ-: Bᴀsʜ, Pʏᴛʜᴏɴ * Linux Administration (RHCSA) 🔴 * DevOps methodologies. * CLA (Certified Linux Admin) * CCA (Certified Container Admin) -̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶- How can I help you? I can help you with the optimization and scalability of your infrastructure with my expertise in Linux, Containers, AWS, and orchestration. From streamlining deployments with Docker and Kubernetes to maximizing cloud efficiency, I'll ensure your systems are robust and scalable. Let's tackle your challenges and take your projects to the next level. Let's connect and discuss how we can collaborate! :) -̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶-̶- ………………………………………………………………… #devops #devsecops #sre