NextCloud AIO help - I want to customize the docker run conditions.

Linode Staff

Hello,

Im running the Nextcloud AIO from the marketplace. Amazing btw!

But, I have a small issue. The AIO is running from docker, and I want to customize the docker run conditions. Specifically, the AIO has borg backup running, and i wish to customize the backup retentions. This will require me to add and env variable to the docker run command.

Taken from the AIO github "You can adjust the retention policy by providing --env BORG_RETENTION_POLICY="--keep-within=7d --keep-weekly=4 --keep-monthly=6" to the docker run command of the mastercontainer (but before the last line nextcloud/all-in-one:latest! If it was started already, you will need to stop the mastercontainer, remove it (no data will be lost) and recreate it using the docker run command that you initially used) and customize the value to your fitting."

I do not know how the marketplace linode was constructed, so i don't know if i can remove the mastercontainer, and recreate with the docker run command.

Can you tell me how i would go about adding this new env variable to the docker run?

Thank you

1 Reply

Well, to accomplish this task we need to get comfortable with managing docker containers via the command line. It's not as complicated as it seems. One of the things the Marketplace app does when it deploys this Linode is install docker and runs the necessary docker command to stand up your containers. Have a look at that command below:

# Install NextCloud
sudo docker run -d \
--name nextcloud-aio-mastercontainer \
--restart always \
-p 80:80 \
-p 8080:8080 \
-p 8443:8443 \
-e NEXTCLOUD_MOUNT=/mnt/ \
-e NEXTCLOUD_DATADIR=/mnt/ncdata \
--volume nextcloud_aio_mastercontainer:/mnt/docker-aio-config \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
nextcloud/all-in-one:latest

Now the beauty of how docker works is, in order to make changes to your containers you just need to stop your container and re-run that command with any additional environment variables you need to add. The NextCloud container will restart with the additional parameters. If there are any syntax errors you'll know right away. Helpful note, you can always view the status of your containers with the following commands:

sudo docker ps    Lists all running containers
sudo docker -ps -a    Lists all containers
sudo docker diff container    Inspects changes to directories and files in the container filesystem
sudo docker top container    Shows all running processes in an existing container
sudo docker inspect container    Displays low-level information about a container
sudo docker logs container    Gathers the logs for a container
sudo docker stats container    Shows container resource usage statistics

I don't want to get too far off course here. So I'll move on to the steps necessary for you to complete your task.

Log into your Linode via SSH or Using the Lish Console. Then follow the steps listed below:

List your Containers and Stop your Docker Containers

sudo docker ps -a
sudo docker stop <nextcloud container-id> 

Make sure all containers are stopped.

sudo docker ls -a

Run your Docker Run Command

sudo docker run -d \
--name nextcloud-aio-mastercontainer \
--restart always \
-p 80:80 \
-p 8080:8080 \
-p 8443:8443 \
-e NEXTCLOUD_MOUNT=/mnt/ \
-e NEXTCLOUD_DATADIR=/mnt/ncdata \
--volume nextcloud_aio_mastercontainer:/mnt/docker-aio-config \
--volume /var/run/docker.sock:/var/run/docker.sock:ro \
--env BORG_RETENTION_POLICY="--keep-within=7d --keep-weekly=4 --keep-monthly=6" \
nextcloud/all-in-one:latest

At this point you should be good to go. It's worth mentioning that every once in awhile you should clear out any unused images (they build up and take up space). You can use the image prue command for this:

sudo docker image prune    Clears an unused image
sudo docker image prune -a    Clears all images that are not being used by containers

Helpful Resources

Credit to @vhumphrey for putting this together

-- Koffi

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct