Install Shaarli Inside Docker Container in Linux

Install Shaarli Inside Docker Container in Linux

Shaarli is a web application for saving and sharing links to websites. It allows users to save links by entering the URL of a webpage and adding a title, description, and tags.

This tutorial explains how to install Shaarli inside a Docker container in the Linux. Commands have been tested on Ubuntu.

Prepare environment

Make sure you have installed Docker in your system. If you are using Ubuntu, installation instructions can be found in the post.

Install Shaarli

Before starting, create directories for data and cache:

sudo mkdir -p /opt/shaarli/{data,cache}

Set user, which ID is 100 as owner for newly created directories:

sudo chown -R 100:101 /opt/shaarli

Note: it doesn't matter that user (ID: 100) doesn't exist on host system. This user will be created in the container.

  • Host network

Run the following command to create a container for Shaarli that uses host network:

docker run -d --name=shaarli --restart=always --network=host \
    -v /opt/shaarli/data:/var/www/shaarli/data \
    -v /opt/shaarli/cache:/var/www/shaarli/cache \
    ghcr.io/shaarli/shaarli
  • User-defined bridge network

User-defined bridge network can be used for listening on different port. By default, Shaarli service is listening on port 80. It can be changed with -p option.

docker network create app-net
docker run -d --name=shaarli --restart=always --network=app-net \
    -p 8080:80 \
    -v /opt/shaarli/data:/var/www/shaarli/data \
    -v /opt/shaarli/cache:/var/www/shaarli/cache \
    ghcr.io/shaarli/shaarli

Testing Shaarli

Open a web browser and go to http://<IP_ADDRESS>, where <IP_ADDRESS> is the IP address of the system. For the first time, you will be asked to create the administrator account. After that, you will be redirected to the login page.

Shaarli Inside Docker Container in Linux

Uninstall Shaarli

To completely remove Shaarli, remove its container:

docker rm --force shaarli

Remove Shaarli image:

docker rmi ghcr.io/shaarli/shaarli

You can also remove Shaarli data:

sudo rm -rf /opt/shaarli

If a user-defined bridge network was created, you can delete it as follows:

docker network rm app-net

Leave a Comment

Cancel reply

Your email address will not be published.