How to install Snippet Box in Docker

by Danny
0 comment

READING TIME: 4 MINUTES

In this guide, I’m going to show you how to install Snippet Box in a Docker container. Snippet Box is an application that lets you organize your code snippets. You can add things docker-compose configs, Powershell scripts, batch files you run, your Homer dashboard configuration, or any other snippets of code you’d like to store and backup for quick access later on.

It’s also useful if don’t use some sort of code-versioning software like Gitea or Github.

As selfhosters and/or IT admins, we often use scripts to simplify or automate a task. How many times have you gotten something working and decided to add functionality to it to make the script better and more efficient, only to realize you don’t have the “working” version anymore? I know I have. Sometimes, I would even save the “working” code to a text file or Bookstack wiki, but that’s just not very efficient.

Snippet Box is customizable, searchable, and you can even copy the saved snippet to your clipboard for quick access.

The solution is to use Snippet Box. If you are using the Flame dashboard, this application comes from the very same developer.

Let’s get started!

This guide assumes you already have Docker installed.


Install Snippet Box in Docker

First, SSH into your Docker host.

Then, create a new directory:

sudo mkdir /srv/config/snippetbox

After that, change directories into that snippetbox folder:

cd /srv/config/snippetbox

And finally, run this command to deploy the Snippet Box container with a bind mount so the data persists after reboot. (The default port is 5000, but I changed it to 5100 since 5000 was already in use)

sudo docker run -p 5100:5000 -v /srv/config/snippetbox:/app/data pawelmalak/snippet-box

After a few seconds, you should see a message in your terminal that looks like this confirming that the container is now running:


Launch Snippet Box in a Browser

Next, open Snippet Box by typing your docker IP and port 5100.

It should be empty by default:

Adding Code Snippets to Snippet Box

This is pretty self-explanatory, but since I wanted to show you what it looks like to add/view some snippets, I’ll show you the process of adding one.

For this example, I’m adding my Sonarr Autostart batch file.

Just add a title, short description, the programming language you are using, the code, and optionally you can add some documentation. None of this gets autofilled for you, so you’ll just need to type it all out.

After adding your first snippet, it will automatically show up in the “Snippets” section, like this:

Like I mentioned earlier, I really like that you can simply copy the code directly from the Snippet page.


Adding Additional Snippets to Snippet-Box

After adding your first snippet, you can add more by clicking the Editor tab.

Once you’ve added a few pieces of code, your snippets page will start to look like this:

However, if you click the Home button, it’ll be empty and only show the search box. To fix that, click the pin next to any item to “pin” them to your homepage.

Your Home page should now look like this:


Wrapping Up

That’s it! Hopefully you found this Docker container as useful as I did. What I typically do is make use of “Tags” for items that are Working, WIP, or Not In Use.

A lot of times you may create a really useful script, never end up using it, but you don’t neccarrily want to totally forget about the script or delete. So, the next best thing is to document it in Snippet Box so you always have it just in case you need it later on!

If you don’t like using tags, you could also append a different title to your code snippet as you make edits. Something like “NZBGet Autostart – Work in Progress” or “NZBGet Autostart – Production”.

0 comment

You may also like

Leave a Comment