Run Snipe-IT in a Docker container on Ubuntu
This guide was written after much trial and error to get Snipe-IT running in a Docker container on an Ubuntu server with Docker Compose. This hopefully will cut out a lot of time for others trying to get their docker-compose.yaml configuration correct.
This guide is written for Ubuntu Server 24.04. Snipe-IT and MariaDB Docker images used are from linuxserver.io hosted on Docker Hub.
Snipe-IT: https://hub.docker.com/r/linuxserver/snipe-it
MariaDB: https://hub.docker.com/r/linuxserver/mariadb
Install Docker Engine
First we need to get Docker installed.
Setup
Reference: https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository
Add Docker's official GPG key:
$ sudo apt install ca-certificates curl $ sudo install -m 0755 -d /etc/apt/keyrings $ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc $ sudo chmod a+r /etc/apt/keyrings/docker.asc
Add the repository to Apt sources:
echo \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Install packages:
$ sudo apt update
$ sudo apt install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
Post-install process
Reference: https://docs.docker.com/engine/install/linux-postinstall/
Add user to Docker group:
$ sudo usermod -aG docker $USER
Activate user in new group:
$ newgrp docker
Configure Docker to start on boot with systemd:
$ sudo systemctl enable docker.service $ sudo systemctl enable containerd.service
Snipe-IT installation
Now it's time to create a couple of directories for data persistence, and pull the Docker images for Snipe-IT and MariaDB by configuring our docker-compose.yaml file.
$ cd ~
$ mkdir snipeitapp snipeitdb $ nano docker-compose.yaml
Enter the following into your docker-compose.yaml file and save it. Note, some lines will need to be changed to suit your environment:
services: snipeitdb: image: linuxserver/mariadb:amd64-latest container_name: snipeitdb restart: unless-stopped volumes: - /home/lcadmin/snipeitdb:/config <change lcadmin to your username> environment: - TZ=Australia/ACT - MYSQL_DATABASE=snipeit - MYSQL_USER=snipeit - MYSQL_PASSWORD=password - MYSQL_ROOT_PASSWORD=password ports: - 3306:3306 snipeitapp: image: linuxserver/snipe-it:amd64-latest container_name: snipeitapp restart: unless-stopped volumes: - /home/lcadmin/snipeitapp:/config <change lcadmin to your username> environment:
- TZ=Australia/ACT
- APP_URL=http://10.0.0.146:8080 <change this to your own url>
- APP_KEY=base64:<get by running "docker compose up" and checking the logs>
- MYSQL_PORT_3306_TCP_ADDR=10.0.0.146 <change this to your own ip> - MYSQL_PORT_3306_TCP_PORT=3306 - MYSQL_DATABASE=snipeit - MYSQL_USER=snipeit - MYSQL_PASSWORD=password ports: - 8080:80 depends_on: - snipeitdb
Run Docker Compose command to start Docker containers specified in .yaml file:
$ docker compose up -d
Snipe-IT web frontend
Access the web frontend at http://10.0.0.146:8080 or <your own ip:8080>.
Data persistence
Your data is written to your home directories on the host; ~/snipeitapp for Snipe-IT configuration, and ~/snipeitdb for the MariaDB database. To test, after initially setting up Snipe-IT via the web interface, run the following to take your container instances down:
docker compose down
Then run the following to bring your containers back up:
docker compose up -d
Any data you entered prior to taking your containers down should still be there.