Project Icon

docker

开源自托管云存储平台 支持多种灵活部署方式

Nextcloud是开源自托管云存储平台,提供数据存储和分享功能。支持Apache和FPM部署,可对接外部数据库和存储。通过环境变量实现自动配置,简化部署。具备命令行界面,支持Redis缓存和SMTP邮件服务,满足企业应用需求。

What is Nextcloud?

GitHub CI build status badge update.sh build status badge amd64 build status badge arm32v5 build status badge arm32v6 build status badge arm32v7 build status badge arm64v8 build status badge i386 build status badge mips64le build status badge ppc64le build status badge s390x build status badge

A safe home for all your data. Access & share your files, calendars, contacts, mail & more from any device, on your terms.

logo

⚠️⚠️⚠️ This image is maintained by community volunteers and designed for expert use. For quick and easy deployment that supports the full set of Nextcloud Hub features, use the Nextcloud All-in-One docker container maintained by Nextcloud GmbH.

How to use this image

This image is designed to be used in a micro-service environment. There are two versions of the image you can choose from.

The apache tag contains a full Nextcloud installation including an apache web server. It is designed to be easy to use and gets you running pretty fast. This is also the default for the latest tag and version tags that are not further specified.

The second option is a fpm container. It is based on the php-fpm image and runs a fastCGI-Process that serves your Nextcloud page. To use this image it must be combined with any webserver that can proxy the http requests to the FastCGI-port of the container.

Try in PWD

Using the apache image

The apache image contains a webserver and exposes port 80. To start the container type:

$ docker run -d -p 8080:80 nextcloud

Now you can access Nextcloud at http://localhost:8080/ from your host system.

Using the fpm image

To use the fpm image, you need an additional web server, such as nginx, that can proxy http-request to the fpm-port of the container. For fpm connection this container exposes port 9000. In most cases, you might want to use another container or your host as proxy. If you use your host you can address your Nextcloud container directly on port 9000. If you use another container, make sure that you add them to the same docker network (via docker run --network <NAME> ... or a docker-compose file). In both cases you don't want to map the fpm port to your host.

$ docker run -d nextcloud:fpm

As the fastCGI-Process is not capable of serving static files (style sheets, images, ...), the webserver needs access to these files. This can be achieved with the volumes-from option. You can find more information in the docker-compose section.

Using an external database

By default, this container uses SQLite for data storage but the Nextcloud setup wizard (appears on first run) allows connecting to an existing MySQL/MariaDB or PostgreSQL database. You can also link a database container, e. g. --link my-mysql:mysql, and then use mysql as the database host on setup. More info is in the docker-compose section.

Persistent data

The Nextcloud installation and all data beyond what lives in the database (file uploads, etc.) are stored in the unnamed docker volume volume /var/www/html. The docker daemon will store that data within the docker directory /var/lib/docker/volumes/.... That means your data is saved even if the container crashes, is stopped or deleted.

A named Docker volume or a mounted host directory should be used for upgrades and backups. To achieve this, you need one volume for your database container and one for Nextcloud.

Nextcloud:

  • /var/www/html/ folder where all Nextcloud data lives
$ docker run -d \
-v nextcloud:/var/www/html \
nextcloud

Database:

  • /var/lib/mysql MySQL / MariaDB Data
  • /var/lib/postgresql/data PostgreSQL Data
$ docker run -d \
-v db:/var/lib/mysql \
mariadb:10.6

Additional volumes

If you want to get fine grained access to your individual files, you can mount additional volumes for data, config, your theme and custom apps. The data, config files are stored in respective subfolders inside /var/www/html/. The apps are split into core apps (which are shipped with Nextcloud and you don't need to take care of) and a custom_apps folder. If you use a custom theme it would go into the themes subfolder.

Overview of the folders that can be mounted as volumes:

  • /var/www/html Main folder, needed for updating
  • /var/www/html/custom_apps installed / modified apps
  • /var/www/html/config local configuration
  • /var/www/html/data the actual data of your Nextcloud
  • /var/www/html/themes/<YOUR_CUSTOM_THEME> theming/branding

If you want to use named volumes for all of these, it would look like this:

$ docker run -d \
-v nextcloud:/var/www/html \
-v apps:/var/www/html/custom_apps \
-v config:/var/www/html/config \
-v data:/var/www/html/data \
-v theme:/var/www/html/themes/<YOUR_CUSTOM_THEME> \
nextcloud

Custom volumes

If mounting additional volumes under /var/www/html, you should consider:

  • Confirming that upgrade.exclude contains the files and folders that should persist during installation and upgrades; or
  • Mounting storage volumes to locations outside of /var/www/html.

[!WARNING] You should note that data inside the main folder (/var/www/html) will be overridden/removed during installation and upgrades, unless listed in upgrade.exclude. The additional volumes officially supported are already in that list, but custom volumes will need to be added by you. We suggest mounting custom storage volumes outside of /var/www/html and if possible read-only so that making this adjustment is unnecessary. If you must do so, however, you may build a custom image with a modified /upgrade.exclude file that incorporates your custom volume(s).

Using the Nextcloud command-line interface

To use the Nextcloud command-line interface (aka. occ command):

$ docker exec --user www-data CONTAINER_ID php occ

or for docker-compose:

$ docker-compose exec --user www-data app php occ

Auto configuration via environment variables

The Nextcloud image supports auto configuration via environment variables. You can preconfigure everything that is asked on the install page on first run. To enable auto configuration, set your database connection via the following environment variables. You must specify all of the environment variables for a given database or the database environment variables defaults to SQLITE. ONLY use one database type!

SQLite:

  • SQLITE_DATABASE Name of the database using sqlite

MYSQL/MariaDB:

  • MYSQL_DATABASE Name of the database using mysql / mariadb.
  • MYSQL_USER Username for the database using mysql / mariadb.
  • MYSQL_PASSWORD Password for the database user using mysql / mariadb.
  • MYSQL_HOST Hostname of the database server using mysql / mariadb.

PostgreSQL:

  • POSTGRES_DB Name of the database using postgres.
  • POSTGRES_USER Username for the database using postgres.
  • POSTGRES_PASSWORD Password for the database user using postgres.
  • POSTGRES_HOST Hostname of the database server using postgres.

As an alternative to passing sensitive information via environment variables, _FILE may be appended to the previously listed environment variables, causing the initialization script to load the values for those variables from files present in the container. See Docker secrets section below.

If you set any group of values (i.e. all of MYSQL_DATABASE, MYSQL_USER, MYSQL_PASSWORD, MYSQL_HOST), they will not be asked in the install page on first run. With a complete configuration by using all variables for your database type, you can additionally configure your Nextcloud instance by setting admin user and password (only works if you set both):

  • NEXTCLOUD_ADMIN_USER Name of the Nextcloud admin user.
  • NEXTCLOUD_ADMIN_PASSWORD Password for the Nextcloud admin user.

If you want, you can set the data directory, otherwise default value will be used.

  • NEXTCLOUD_DATA_DIR (default: /var/www/html/data) Configures the data directory where nextcloud stores all files from the users.

One or more trusted domains can be set through environment variable, too. They will be added to the configuration after install.

  • NEXTCLOUD_TRUSTED_DOMAINS (not set by default) Optional space-separated list of domains

The install and update script is only triggered when a default command is used (apache-foreground or php-fpm). If you use a custom command you have to enable the install / update with

  • NEXTCLOUD_UPDATE (default: 0)

You might want to make sure the htaccess is up to date after each container update. Especially on multiple swarm nodes as any discrepancy will make your server unusable.

  • NEXTCLOUD_INIT_HTACCESS (not set by default) Set it to true to enable run occ maintenance:update:htaccess after container initialization.

If you want to use Redis you have to create a separate Redis container in your setup / in your docker-compose file. To inform Nextcloud about the Redis container, pass in the following parameters:

  • REDIS_HOST (not set by default) Name of Redis container
  • REDIS_HOST_PORT (default: 6379) Optional port for Redis, only use for external Redis servers that run on non-standard ports.
  • REDIS_HOST_PASSWORD (not set by default) Redis password

The use of Redis is recommended to prevent file locking problems. See the examples for further instructions.

To use an external SMTP server, you have to provide the connection details. Note that if you configure these values via Docker, you should not use the Nexcloud Web UI to configure external SMTP server parameters. Conversely, if you prefer to use the Web UI, do not set these variables here (because these variables will override whatever you attempt to set in the Web UI for these parameters). To configure Nextcloud to use SMTP add:

  • SMTP_HOST (not set by default): The hostname of the SMTP server.
  • SMTP_SECURE (empty by default): Set to ssl to use SSL, or tls to use STARTTLS.
  • SMTP_PORT (default: 465 for SSL and 25 for non-secure connections): Optional port for the SMTP connection. Use 587 for an alternative port for STARTTLS.
  • SMTP_AUTHTYPE (default: LOGIN): The method used for authentication. Use PLAIN if no authentication is required.
  • SMTP_NAME (empty by default): The username for the authentication.
  • SMTP_PASSWORD (empty by default): The password for the authentication.
  • MAIL_FROM_ADDRESS (not set by default): Set the local-part for the 'from' field in the emails sent by Nextcloud.
  • MAIL_DOMAIN (not set by default): Set a different domain for the emails than the domain where Nextcloud is installed.

At least SMTP_HOST, MAIL_FROM_ADDRESS and MAIL_DOMAIN must be set for the configurations to be applied.

Check the Nextcloud documentation for other values to configure SMTP.

To use an external S3 compatible object store as primary storage, set the following variables:

  • OBJECTSTORE_S3_BUCKET: The name of the bucket that Nextcloud should store the data in
  • OBJECTSTORE_S3_REGION: The region that the S3 bucket resides in
  • OBJECTSTORE_S3_HOST: The hostname of the object storage server
  • OBJECTSTORE_S3_PORT: The port that the object storage server is being served over
  • OBJECTSTORE_S3_KEY: AWS style access key
  • OBJECTSTORE_S3_SECRET: AWS style secret access key
  • OBJECTSTORE_S3_STORAGE_CLASS: The storage class to use when adding objects to the bucket
  • OBJECTSTORE_S3_SSL (default: true): Whether or not SSL/TLS should be used to communicate with object storage server
  • OBJECTSTORE_S3_USEPATH_STYLE (default: false): Not required for AWS S3
  • OBJECTSTORE_S3_LEGACYAUTH (default: false): Not required for AWS S3
  • OBJECTSTORE_S3_OBJECT_PREFIX (default: urn:oid:): Prefix to prepend to the fileid
  • OBJECTSTORE_S3_AUTOCREATE (default: true): Create the container if it does not exist
  • OBJECTSTORE_S3_SSE_C_KEY (not set by default): Base64 encoded key with a maximum length of 32 bytes for server side encryption (SSE-C)

Check the Nextcloud documentation for more information.

To use an external OpenStack Swift object store as primary storage, set the following variables:

  • OBJECTSTORE_SWIFT_URL: The Swift identity (Keystone) endpoint
  • OBJECTSTORE_SWIFT_AUTOCREATE (default: false): Whether or not Nextcloud should automatically create the Swift container
  • OBJECTSTORE_SWIFT_USER_NAME: Swift username
  • OBJECTSTORE_SWIFT_USER_PASSWORD: Swift user password
  • OBJECTSTORE_SWIFT_USER_DOMAIN (default: Default): Swift user domain
  • OBJECTSTORE_SWIFT_PROJECT_NAME: OpenStack project name
  • OBJECTSTORE_SWIFT_PROJECT_DOMAIN (default: Default): OpenStack project domain
  • OBJECTSTORE_SWIFT_SERVICE_NAME (default: swift): Swift service name
  • OBJECTSTORE_SWIFT_REGION: Swift endpoint region
  • OBJECTSTORE_SWIFT_CONTAINER_NAME: Swift container (bucket) that Nextcloud should store the data in

Check the Nextcloud documentation for more information.

To customize other PHP limits you can simply change the following variables:

  • PHP_MEMORY_LIMIT
项目侧边栏1项目侧边栏2
推荐项目
Project Cover

豆包MarsCode

豆包 MarsCode 是一款革命性的编程助手,通过AI技术提供代码补全、单测生成、代码解释和智能问答等功能,支持100+编程语言,与主流编辑器无缝集成,显著提升开发效率和代码质量。

Project Cover

AI写歌

Suno AI是一个革命性的AI音乐创作平台,能在短短30秒内帮助用户创作出一首完整的歌曲。无论是寻找创作灵感还是需要快速制作音乐,Suno AI都是音乐爱好者和专业人士的理想选择。

Project Cover

有言AI

有言平台提供一站式AIGC视频创作解决方案,通过智能技术简化视频制作流程。无论是企业宣传还是个人分享,有言都能帮助用户快速、轻松地制作出专业级别的视频内容。

Project Cover

Kimi

Kimi AI助手提供多语言对话支持,能够阅读和理解用户上传的文件内容,解析网页信息,并结合搜索结果为用户提供详尽的答案。无论是日常咨询还是专业问题,Kimi都能以友好、专业的方式提供帮助。

Project Cover

阿里绘蛙

绘蛙是阿里巴巴集团推出的革命性AI电商营销平台。利用尖端人工智能技术,为商家提供一键生成商品图和营销文案的服务,显著提升内容创作效率和营销效果。适用于淘宝、天猫等电商平台,让商品第一时间被种草。

Project Cover

吐司

探索Tensor.Art平台的独特AI模型,免费访问各种图像生成与AI训练工具,从Stable Diffusion等基础模型开始,轻松实现创新图像生成。体验前沿的AI技术,推动个人和企业的创新发展。

Project Cover

SubCat字幕猫

SubCat字幕猫APP是一款创新的视频播放器,它将改变您观看视频的方式!SubCat结合了先进的人工智能技术,为您提供即时视频字幕翻译,无论是本地视频还是网络流媒体,让您轻松享受各种语言的内容。

Project Cover

美间AI

美间AI创意设计平台,利用前沿AI技术,为设计师和营销人员提供一站式设计解决方案。从智能海报到3D效果图,再到文案生成,美间让创意设计更简单、更高效。

Project Cover

AIWritePaper论文写作

AIWritePaper论文写作是一站式AI论文写作辅助工具,简化了选题、文献检索至论文撰写的整个过程。通过简单设定,平台可快速生成高质量论文大纲和全文,配合图表、参考文献等一应俱全,同时提供开题报告和答辩PPT等增值服务,保障数据安全,有效提升写作效率和论文质量。

投诉举报邮箱: service@vectorlightyear.com
@2024 懂AI·鲁ICP备2024100362号-6·鲁公网安备37021002001498号