How To Install SnipeIT In Docker

by Danny
9 comments

READING TIME: 3 MINUTES

In this guide, I’m going to show you a quick and easy way to install SnipeIT in Docker in 2021, then this simple step by step guide is for you.

SnipeIT, for those of you who don’t know, is an open source asset and license management tool. It’s great for tracking physical assets like laptops, desktops, and software licenses.

For reference, I am installing this on a Ubuntu 20.04 VM, which already has docker installed. If you don’t have docker or Docker installed yet, you can follow Docker Setup Guide.


Create Folders

Use Putty to SSH into your docker host. I like to start out by putting my containers into the same directory, so I’m first going to create a parent SnipeIT folder.

All of my containers typically go into /srv/config, so that’s where I’ll be creating it.

First, navigate to the config folder:

cd /srv/config

Then, create the folder by entering sudo mkdir snipeit

Next, go into the snipeit directory:

cd snipeit

Then, create two new directories

sudo mkdir snipe-mysql
sudo mkdir snipe-conf


Create MySQL Container

To create the mysql database container, just run the code below. You can change the ROOT and MYSQL passwords, if you’d like to. Also, make sure the timezone is set to your correct location.

docker run \
--name snipe-mysql \
-d \
-e MYSQL_ROOT_PASSWORD="Goldpumpkineagle4" \
-e MYSQL_DATABASE=snipe \
-e MYSQL_USER=snipe \
-e MYSQL_PASSWORD="Wolfhungrysunset8" \
-e TZ=America/Chicago \
-p 127.0.0.1:3306:3306 \
-v /srv/config/snipeit/snipe-mysql:/var/lib/mysql \
mysql:5.6 --sql-mode=""


Create SnipeIT Container

Now, you can create the main SnipeIT container.

docker create \
--name=snipe-it \
--link snipe-mysql:db \
-e PUID=1000 \
-e PGID=1000 \
-e DB_CONNECTION=mysql \
-e DB_HOST=snipe-mysql \
-e DB_DATABASE=snipe \
-e DB_USERNAME=snipe \
-e DB_PASSWORD="Wolfhungrysunset8" \
-e APP_KEY=base64:5U/KPKw1GN/Rz0fWYO/4FsSOqjmjvDAQzMCqwcAqstc= \
-p 8082:80 \
-v /srv/config/snipeit/snipe-conf:/config \
--restart unless-stopped \
snipe/snipe-it

Keep in mind – the DB_PASSWORD will use the MYSQL_PASSWORD in the first container you created.


Launch SnipeIT

Now that both containers are created, you can enter this command to run it. Once complete, SnipeIT should open in a web browser at port 8082.

docker start snipe-it

If all goes well, you should be able to browse to the IP of your docker host (172.16.0.41:8092) in a web browser and you’ll be met with a SnipeIT Pre-Flight screen like this:

Wrapping Up

That’s it! You can run your own instance of open source asset management software in a docker container. I’ve been using SnipeIT (hosted) at my company for the past 5 years, and it’s one of my favorite pieces of software to use. We primarily use it for license management, but in the past (before PDQ Inventory), we used to use it for asset management as well. There are some really neat features for consumable objects too, such as toner, paper, SSD’s, etc.

9 comments

You may also like

9 comments

Edi May 15, 2021 - 10:32 pm

Hi, very nice and helpful description, thank you! My only problem is, that at the step, where I should create the Snipe-IT container, I get an error message with “Unable to find image ‘snipe:latest’ “, what in my mind is ok, since the correct image is “snipe/snipe-it:latest”. I tried to change the DB_DATABASE line to snipe/snipe-it (what shouldn’t be right, since it belongs to the MySQL data?) and received a long line of characters and numbers. After that I launched with “docker start snipe-it” and received “Error response from daemon: OCI runtime create failed: container_linux.go:367: starting container process caused: exec: “-e”: executable file not found in $PATH: unknown
Error: failed to start containers: snipe-it” I’ve also installed Portainer.io, where I couldn’t find any container with snipe-it. So I was wondering, where in the lines is the information hidden regards “snipe:latest” so I can change it? Grateful for a response, best regards: Edi

Reply
Danny May 16, 2021 - 2:57 am

What usually happens when Docker can’t find the image is that it downloads the latest version automatically. Have you tried manually downloading it? Try this: sudo docker pull snipe/snipe-it

Then, run the script exactly as my script in the guide once it’s downloaded (changing ports & usernames/passwords, if you want).

Reply
Anonima July 19, 2021 - 10:45 am

I got this error when trying to start container.
Error response from daemon: Cannot link to a non running container: /snipe-mysql AS /snipe-it/db
Error: failed to start containers: snipe-it

Reply
Danny July 19, 2021 - 2:07 pm

Do you have another Snipe-IT container created, but not running? Possibly from testing? The easiest way to fix this is by creating a new SnipeIT container and giving it a new name

Reply
Numair September 5, 2021 - 7:13 am

All goes well but when i open the browser it only shows blank screen with a snipe-it logo on address bar.

Reply
Danny September 5, 2021 - 10:01 am

It doesn’t sound like it completed the install correctly. Maybe check the logs to ensure everything is running?

Reply
Henrik September 15, 2021 - 1:58 am

I also got the blank screen with address bar. But it was due to php being too old. I had to add a php repository and pull down php 7.14 for it to work, otherwise it just came with php 5.4 and that wont work.

Reply
Henrik September 15, 2021 - 2:00 am

* forgot to add, I was doing this on a CentOS 7 box.

Reply
Danny September 15, 2021 - 2:04 am

Awesome, thanks for the tip!

Reply

Leave a Comment