You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

198 lines
5.3 KiB

  1. ---
  2. date: "2016-12-01T16:00:00+02:00"
  3. title: "Installation with Docker"
  4. slug: "install-with-docker"
  5. weight: 10
  6. toc: true
  7. draft: false
  8. menu:
  9. sidebar:
  10. parent: "installation"
  11. name: "With Docker"
  12. weight: 10
  13. identifier: "install-with-docker"
  14. ---
  15. # Installation with Docker
  16. We provide automatically updated Docker images within our Docker Hub organization. It is up to you and your deployment to always use the latest stable tag or to use another service that updates the Docker image for you.
  17. This reference setup guides you through the setup based on `docker-compose`, the installation of `docker-compose` is out of scope of this documentation. To install `docker-compose` follow the official [install instructions](https://docs.docker.com/compose/install/).
  18. ## Basics
  19. The most simple setup just creates a volume and a network and starts the `gitea/gitea:latest` image as a service. Since there is no database available you can start it only with SQLite3. Create a directory like `gitea` and paste the following content into a file named `docker-compose.yml`.
  20. ```yaml
  21. version: "2"
  22. networks:
  23. gitea:
  24. external: false
  25. services:
  26. server:
  27. image: gitea/gitea:latest
  28. restart: always
  29. networks:
  30. - gitea
  31. volumes:
  32. - ./gitea:/data
  33. ports:
  34. - "3000:3000"
  35. - "222:22"
  36. ```
  37. ## Custom port
  38. To bind the integrated openSSH daemon and the webserver on a different port, you just need to adjust the port section. It's common to just change the host port and keep the ports within the container like they are.
  39. ```diff
  40. version: "2"
  41. networks:
  42. gitea:
  43. external: false
  44. services:
  45. server:
  46. image: gitea/gitea:latest
  47. restart: always
  48. networks:
  49. - gitea
  50. volumes:
  51. - ./gitea:/data
  52. ports:
  53. - - "3000:3000"
  54. - - "222:22"
  55. + - "8080:3000"
  56. + - "2221:22"
  57. ```
  58. ## MySQL database
  59. To start Gitea in combination with a MySQL database you should apply these changes to the `docker-compose.yml` file created above.
  60. ```diff
  61. version: "2"
  62. networks:
  63. gitea:
  64. external: false
  65. services:
  66. server:
  67. image: gitea/gitea:latest
  68. restart: always
  69. networks:
  70. - gitea
  71. volumes:
  72. - ./gitea:/data
  73. ports:
  74. - "3000:3000"
  75. - "222:22"
  76. + depends_on:
  77. + - db
  78. +
  79. + db:
  80. + image: mysql:5.7
  81. + restart: always
  82. + environment:
  83. + - MYSQL_ROOT_PASSWORD=gitea
  84. + - MYSQL_USER=gitea
  85. + - MYSQL_PASSWORD=gitea
  86. + - MYSQL_DATABASE=gitea
  87. + networks:
  88. + - gitea
  89. + volumes:
  90. + - ./mysql:/var/lib/mysql
  91. ```
  92. ## PostgreSQL database
  93. To start Gitea in combination with a PostgreSQL database you should apply these changes to the `docker-compose.yml` file created above.
  94. ```diff
  95. version: "2"
  96. networks:
  97. gitea:
  98. external: false
  99. services:
  100. server:
  101. image: gitea/gitea:latest
  102. restart: always
  103. networks:
  104. - gitea
  105. volumes:
  106. - ./gitea:/data
  107. ports:
  108. - "3000:3000"
  109. - "222:22"
  110. + depends_on:
  111. + - db
  112. +
  113. + db:
  114. + image: postgres:9.6
  115. + restart: always
  116. + environment:
  117. + - POSTGRES_USER=gitea
  118. + - POSTGRES_PASSWORD=gitea
  119. + - POSTGRES_DB=gitea
  120. + networks:
  121. + - gitea
  122. + volumes:
  123. + - ./postgres:/var/lib/postgresql/data
  124. ```
  125. ## Named volumes
  126. To use named volumes instead of host volumes you just have to define and use the named volume within the `docker-compose.yml` configuration. This change will automatically create the required volume.
  127. ```diff
  128. version: "2"
  129. networks:
  130. gitea:
  131. external: false
  132. +volumes:
  133. + gitea:
  134. + driver: local
  135. +
  136. services:
  137. server:
  138. image: gitea/gitea:latest
  139. restart: always
  140. networks:
  141. - gitea
  142. volumes:
  143. - - ./gitea:/data
  144. + - gitea:/data
  145. ports:
  146. - "3000:3000"
  147. - "222:22"
  148. ```
  149. If you are using MySQL or PostgreSQL it's up to you to create named volumes for these containers as well.
  150. ## Start
  151. To start this setup based on `docker-compose` you just have to execute `docker-compose up -d` to launch Gitea in the background. You can see if it started properly via `docker-compose ps`, and you can tail the log output via `docker-compose logs`.
  152. If you want to shutdown the setup again just execute `docker-compose down`, this will stop and kill the containers, the volumes will still exist.
  153. Notice: if you use a non 3000 port on http, you need change app.ini `LOCAL_ROOT_URL = http://localhost:3000/`.
  154. ## Install
  155. After starting the Docker setup via `docker-compose` you should access Gitea with your favorite browser to finalize the installation. Please visit http://server-ip:3000 and follow the installation wizard. If you have started a database with the `docker-compose` setup as documented above please note that you have to use `db` as the database hostname.
  156. # Customization
  157. Customization files described [here](https://docs.gitea.io/en-us/customizing-gitea/) should be placed in `/data/gitea` directory. If you are using host volumes it's quite easy to access these files, for named volumes you have to do it through another container or you should directly access `/var/lib/docker/volumes/gitea_gitea/_data`. The configuration file will be saved at `/data/gitea/conf/app.ini` after the installation.
  158. # Anything missing?
  159. Are we missing anything on this page? Then feel free to reach out to us on our [Discord server](https://discord.gg/NsatcWJ), there you will get answers to any question pretty fast.