使用DOCKER COMPOSE搭建一个nextcloud服务

1.创建一个空的项目目录并切换到该项目目录

  1. [root@localhost ~]# mkdir my_nextcloud ; cd my_nextcloud ; pwd
  2. /root/my_nextcloud

2.创建Docker-compose文件

  1. version: "3.9"
  2. services:
  3. db:
  4. image: mysql:latest
  5. volumes:
  6. - ./nc_db:/var/lib/mysql
  7. networks:
  8. - nc_net
  9. ports:
  10. - "3306:3306"
  11. restart: always
  12. environment:
  13. MYSQL_ROOT_PASSWORD: nextcloud
  14. MYSQL_DATABASE: nextcloud
  15. MYSQL_USER: nextcloud
  16. MYSQL_PASSWORD: nextcloud
  17. app:
  18. depends_on:
  19. - db
  20. image: nextcloud:latest
  21. volumes:
  22. - ./nc_data:/var/www/html
  23. networks:
  24. - nc_net
  25. ports:
  26. - "8888:80"
  27. restart: always
  28. volumes:
  29. nc_db: {}
  30. nc_data: {}
  31. networks:
  32. nc_net:
  33. name: nc_net

3.运行docker-compose

  1. [root@localhost my_nextcloud]# docker-compose up -d
  2. Creating network "nc_net" with the default driver
  3. Creating volume "my_nextcloud_nc_db" with default driver
  4. Creating volume "my_nextcloud_nc_data" with default driver
  5. Pulling db (mysql:latest)...
  6. latest: Pulling from library/mysql
  7. 72a69066d2fe: Already exists
  8. 93619dbc5b36: Already exists
  9. 99da31dd6142: Already exists
  10. 626033c43d70: Already exists
  11. 37d5d7efb64e: Already exists
  12. ac563158d721: Already exists
  13. d2ba16033dad: Already exists
  14. 688ba7d5c01a: Pull complete
  15. 00e060b6d11d: Pull complete
  16. 1c04857f594f: Pull complete
  17. 4d7cfa90e6ea: Pull complete
  18. e0431212d27d: Pull complete
  19. Digest: sha256:e9027fe4d91c0153429607251656806cc784e914937271037f7738bd5b8e7709
  20. Status: Downloaded newer image for mysql:latest
  21. Pulling app (nextcloud:latest)...
  22. latest: Pulling from library/nextcloud
  23. a2abf6c4d29d: Already exists
  24. c5608244554d: Already exists
  25. 2d07066487a0: Already exists
  26. 1b6dfaf1958c: Already exists
  27. 32c5e6a60073: Already exists
  28. 90cf855b27cc: Already exists
  29. 8b0f1068c586: Already exists
  30. 53530861540e: Pull complete
  31. b088256e8218: Pull complete
  32. 29c48e642f3d: Pull complete
  33. bebfd59a832e: Pull complete
  34. 3c07d6be5322: Pull complete
  35. 52a174ca2213: Pull complete
  36. 2db451f4f766: Pull complete
  37. 462c9168620c: Pull complete
  38. 5f6a7ae88b1d: Pull complete
  39. 8507904d39d6: Pull complete
  40. f6dc5bb9d193: Pull complete
  41. d57202c49578: Pull complete
  42. 57f778f1c66e: Pull complete
  43. Digest: sha256:bd3406506335b6621b1eb7a3d897654ac7963e3db4b91cbea3436f159655d0ba
  44. Status: Downloaded newer image for nextcloud:latest
  45. Creating my_nextcloud_db_1 ... done
  46. Creating my_nextcloud_app_1 ... done

image.png
image.png