Install Lychee Inside Docker Container in Linux

Install Lychee Inside Docker Container in Linux

Lychee is a web-based photo management tool that can be used to upload, manage and share photos. Lychee is an open-source project available under the MIT license.

This tutorial explains how to install Lychee 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.

You also need to have a running MySQL container. Instructions can be found in the post.

Install Lychee

Before starting, create lychee database:

docker exec -it mysql mysql -u root -p -e "CREATE DATABASE lychee"
  • Host network

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

docker run -d --name=lychee --restart=always --network=host \
    -v /opt/lychee/uploads:/uploads \
    -v /opt/lychee/sym:/sym \
    -v /opt/lychee/conf:/conf \
    -e DB_CONNECTION=mysql \
    -e DB_USERNAME=root \
    -e DB_PASSWORD=pwd123 \
    -e DB_DATABASE=lychee \
    -e DB_HOST=127.0.0.1 \
    lycheeorg/lychee

MySQL container should run on host network as well.

  • User-defined bridge network

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

docker network create app-net
docker run -d --name=lychee --restart=always --network=app-net \
    -p 8080:80 \
    -v /opt/lychee/uploads:/uploads \
    -v /opt/lychee/sym:/sym \
    -v /opt/lychee/conf:/conf \
    -e DB_CONNECTION=mysql \
    -e DB_USERNAME=root \
    -e DB_PASSWORD=pwd123 \
    -e DB_DATABASE=lychee \
    -e DB_HOST=mysql \
    lycheeorg/lychee

MySQL container should run on the same user-defined bridge network as well.

Notes:

  • The DB_USERNAME and DB_PASSWORD can be used to specify MySQL credentials.
  • When user-defined bridge network is used, don't forget to change DB_HOST. It specifies MySQL container name.

Testing Lychee

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 can log in to the web interface.

Lychee Inside Docker Container in Linux

Uninstall Lychee

To completely remove Lychee, remove its container:

docker rm --force lychee

Remove Lychee image:

docker rmi lycheeorg/lychee

You can also remove Lychee data:

sudo rm -rf /opt/lychee

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.