This guide outlines the steps for Dockerizing the Plex Dupefinder Python application using Docker.
Ensure that your project has the following folder structure:
plex_dupefinder/
│
└── app/
└── Dockerfile # (Included from git checkout)
└── ... (all contents from the git checkout)
plex_dupefinder/
: Root directory for the Plex Dupefinder project.app/
: Contains all files and directories retrieved from the git checkout, including the Dockerfile.
Follow these steps to set up the folder structure and retrieve your Python application files:
- Open a terminal and navigate to the desired directory for your project.
- Run the following command to clone your repository and create the
app/
folder:git clone https://github.com/Hossy/plex_dupefinder.git app
This command clones your repository and creates the /app
folder containing all files and directories from the git checkout, including the Dockerfile.
Follow these steps to build the Docker image for your Python application:
- Open a terminal and navigate to the root directory of your project.
- Run the following command to build the Docker image:
docker build -t plex_dupefinder app
This command builds the Docker image named plex_dupefinder
using the Dockerfile located in the app/
directory.
To preserve the locally-built image when running docker system prune
, follow these additional steps:
-
When building the Docker image, add a label to it using the
--label
flag:docker build -t plex_dupefinder --label "preserve=true" app
This command adds the label
preserve=true
to theplex_dupefinder
image. -
When running
docker system prune
, use the--filter
flag to exclude images with thepreserve=true
label:docker system prune -af --filter "label!=preserve=true"
This command prunes all unused data (containers, networks, volumes, and images) except those with the
preserve=true
label, ensuring that the locally-built image is preserved from deletion.
Once the Docker image is built, you can run it as a Docker container using the following steps:
-
Run the following command to start a Docker container from the image:
docker run --rm --name plex_dupefinder -v plex_dupefinder/app:/app plex_dupefinder
- Replace
plex_dupefinder/app
with the absolute path to theapp/
directory on your system.
- Replace
-
If running with
SKIP_OTHER_DUPES=false
, add the-i
option to thedocker run
command:docker run -i --rm --name plex_dupefinder -v plex_dupefinder/app:/app plex_dupefinder
The
-i
option ensures interactive mode, allowing input to be sent to the container.