DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Newsletter
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Related

  • A Practical Pipeline for Identifying Sensitive Columns Before Test Data Masking
  • Generate Random Test Data in PostgreSQL
  • Unit Testing SQL Queries Across Multiple Database Platforms
  • A Developer's Guide to Mastering Docker Networking Concepts

Trending

  • Building a Software Factory With AI Agents and Workflows
  • AI-Era Cybersecurity, Part 1: Mapping Glasswing, Daybreak, Lightwell and the Tools Racing to Find and Fix Bugs
  • AI Coding Agent Guardrails: Finding Gaps in Tool Permissions
  • When One Docker Swarm Replica Became Unreachable Over an Overlay Network: A Production Case With Traefik

Draft This article hasn't been published, so readers can't see it.

In moderation This article is waiting for review, so readers can't see it yet.

Deleted This article has been deleted, so readers can't see it.

  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. dksnap: Docker Snapshots for Development and Test Data

dksnap: Docker Snapshots for Development and Test Data

Learn more about dksnap, which allows you to create and manage snapshots of Docker containers.

By 
Ethan J Jackson
·
Mar. 11, 20 · Tutorial
Post on X (opens in a new tab) Share on LinkedIn (opens in a new tab)
6.2K Views

Join the DZone community Save articles, join the discussion, and download Refcards and Trend Reports with a free account.

Join for free Already a member? Log in

dksnap allows you to create and manage snapshots of Docker containers. We expect this to be especially useful for developers working with database containers locally. Check dksnap out on GitHub!

Local Development and Test Data

One of the best things about working at Kelda is that we get to talk with tons of developers who are in the weeds building microservices every day. We hear about all the benefits of containerized development and some of the challenges as well. One such challenge is managing test data during local development and testing.

First, some context: most of the developers we're working with are using Docker locally to work on one or more containers that depend on a database of some sort. In production, of course, they use a production database managed by the ops team. However, when working locally, accessing the production database typically isn't feasible. Instead, devs tend to grab a Postgres, MySQL, or Mongo container from Docker Hub.

The trouble begins when that database needs to be populated with data, this typically requires annoying manual setup work that can take quite a long time to get right. Once all the work has been done to get the database container set up just right, the last thing you want is to have to do it again. However, eventually, tests get run, data gets stale, containers get restarted, life happens, and you end up back where you started — with a bunch of manual setup work in front of you.

You might also like: Docker Explained – An Introductory Guide to Docker

dksnap

dksnap is a tool that allows you to create, view, and rollback snapshots of containers in real-time without needing to fiddle with bash scripts or memorize complicated docker commands.

Once you've set up your container precisely the way you like, you can create a snapshot. That done, you can manipulate your data however you'd like, knowing that you can instantly revert to a previously working state in seconds.

In addition to the core snapshot functionality, dksnap allows you to replace a running container using any snapshot that you've created, and provides a tree view of all your snapshots along with a diff that shows you how they've changed over time.

dksnap has three key features that aren't easily replicated with the standard Docker CLI.

  • First, it's volume aware. Most database containers use volumes, which docker commit doesn't capture.
  • Second, it's database aware. dksnap knows how to talk to Mongo, Postgres, and MySQL, allowing it to dump and restore data politely, and giving it the ability to show diffs between different snapshot versions.
  • Last but not least, it has a simple and intuitive user interface that hides the complexity required for docker snapshots.

Try dksnap

Getting started with dksnap is simple. This tool is a single go binary that you can install by running the following in a terminal:

Shell
 




xxxxxxxxxx
1


 
1
curl https://kelda.io/install-dksnap.sh | sh



Or, if you prefer, download the latest release and copy it to your $PATH.

If you've already got containers running on your local machine,  dksnap opens a new terminal GUI that allows you to create, replace, and view snapshots of your containers.

Otherwise, if you'd like to try out dksnap, we've created a simple demo along with step-by-step instructions so that you can see how it works.


Java
 




xxxxxxxxxx
1
10


 
1
# Download the demo.
2
git clone https://github.com/kelda/dksnap.git
3
cd dksnap/demo
4

          
5
# Start the example application. 
6
# You can access it in your browser at localhost:8080.
7
docker-compose up -d
8

          
9
# Use dksnap to create snapshots of the entries in the Mongo database.
10
dksnap



Get Involved

dksnap is currently in alpha. It is ready for daily use but is still undergoing substantial development. If you find this useful or interesting, please consider joining the community and providing us with your thoughts.

Here are some ways that you can get involved:

  • Start using dksnap today with your work or personal projects
  • Fork the repo and poke around
  • If you have any suggestions, open an issue
  • Join the slack

We look forward to hearing from you!

Docker (software) Test data Snapshot (computer storage) Database

Published at DZone with permission of Ethan J Jackson. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • A Practical Pipeline for Identifying Sensitive Columns Before Test Data Masking
  • Generate Random Test Data in PostgreSQL
  • Unit Testing SQL Queries Across Multiple Database Platforms
  • A Developer's Guide to Mastering Docker Networking Concepts

Partner Resources

×

Comments

Loading comments

The comments didn't load

Please try again in a moment.

Likes

Loading

The next likes didn't load. Please try again.

The likes didn't load

Please try again in a moment.

See who liked this

Log in or join DZone for free to see who liked this article.

Log in Join for free
  • RSS
  • X
  • Facebook

ABOUT US

  • About DZone
  • Support and feedback
  • Community research

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 215
  • Nashville, TN 37211
  • [email protected]

Let's be friends:

  • RSS
  • X
  • Facebook