Post

Deploy Snipe-IT Container in Docker

Today I’m gong to walk through the deployment of Snipe-IT using a Docker compose file, which will setup the software, recommended database. and phpMyAdmin as a UI for the database in case you want/need to access the data directly. If not, feel free to comment or remove the part of the compose file responsible for setting it up.

Although I’ve used Snipe-IT for several years, I first deployed and tested the docker container a few months ago in my homelab, and then, more recently, I installed it in a commercial environment for a client whose paid network monitoring tool wasn’t robust enough to provide the results they were hoping for.

If you haven’t seen my Snipe-IT review, visit this page to learn more about how you may be able to use this product in your home or business.

My Environment

In both environments, I ran the docker compose file on Ubuntu Server (22.04) virtual machines - one in Unraid and the other in VMWare - and the results were successful in both cases.

Whenever I setup a Ubuntu Server for use as a docker host, I immediately create a directory called docker-data in which to store all my applcation data, such as docker compose files and folder mapping etc.

Docker Compose

snipeit/docker-compose.yaml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
version: "3"
services:
  snipe-it:
    image: lscr.io/linuxserver/snipe-it:latest
    container_name: snipe-it
    environment:
      - PUID=1002
      - PGID=1002
      - TZ= #enter local timezone
      - APP_URL=http(s)://server.domain.com/app #set this up first
      - MYSQL_PORT_3306_TCP_ADDR=192.168.1.x #enter target IP address
      - MYSQL_PORT_3306_TCP_PORT=3306 # default port
      - MYSQL_DATABASE=snipeitapp
      - MYSQL_USER=snipeit_user
      - MYSQL_PASSWORD=snipeit_password
      - APP_ENV=production #optional
      - APP_DEBUG=false #optional
      - APP_LOCALE=
      # optional configuration for SMTP
      - MAIL_PORT_587_TCP_ADDR=
      - MAIL_PORT_587_TCP_PORT=
      - MAIL_ENV_FROM_ADDR=snipeit@domain.com
      - MAIL_ENV_FROM_NAME=Snipe-IT@domain.com
      - MAIL_ENV_ENCRYPTION=null
      - MAIL_ENV_USERNAME=snipeit_user@domain.com
      - MAIL_ENV_PASSWORD=snipeit_user_password
    volumes:
      - ./snipeit_app_data:/config
    ports:
      - "9080:80"
    restart: unless-stopped
    depends_on:
      - snipeit_db

  snipeit_db:
    image: linuxserver/mariadb
    container_name: snipeit_db
    environment:
      - PUID=1002
      - PGID=1002
      - MYSQL_ROOT_PASSWORD=strong_root_password
      - TZ=
      - MYSQL_DATABASE=snipeitapp
      - MYSQL_USER=snipeit_usr
      - MYSQL_PASSWORD=snipeit_usr_secure_pw
    volumes:
      - ./snipeit_db_data:/config
    ports:
      - "3306:3306"
    restart: unless-stopped

  snipeit_sqladm:
    image: phpmyadmin/phpmyadmin
    container_name: snipeit_sqladm
    restart: always
    environment:
      PMA_HOST: 192.168.1.x # same IP address as docker host
      PMA_USER: snipeit_usr
      PMA_PASSWORD: snipeit_usr_secure_pw
    ports:
      - "8070:80"
    depends_on:
      - snipeit_db

Clear Cache

After making changes, clear Snipe-IT’s cache using php artisan config:clear and php artisan config:cache within the container.

1
2
/app/www# php artisan config:clear
/app/www# php artisan config:cache

Reverse Proxy Snippet

1
2
3
4
5
6
7
8
  location /itam/ {
  # Rewrite the "/itam" part to the actual path within Snipe-IT
    rewrite ^/itam/(.*) /$1 break;
    proxy_pass http://192.168.1.27:9080;
#    proxy_set_header Host $host;
#    proxy_set_header X-Real-IP $remote_addr;
#    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
This post is licensed under CC BY 4.0 by the author.