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

with-docker.en-us.md 5.0 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217
  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. Gitea provides automatically updated Docker images within its Docker Hub organization. It is
  17. possible to always use the latest stable tag or to use another service that handles updating
  18. Docker images.
  19. This reference setup guides users through the setup based on `docker-compose`, the installation
  20. of `docker-compose` is out of scope of this documentation. To install `docker-compose` follow
  21. the official [install instructions](https://docs.docker.com/compose/install/).
  22. ## Basics
  23. The most simple setup just creates a volume and a network and starts the `gitea/gitea:latest`
  24. image as a service. Since there is no database available one can be initialized using SQLite3.
  25. Create a directory like `gitea` and paste the following content into a file named `docker-compose.yml`.
  26. ```yaml
  27. version: "2"
  28. networks:
  29. gitea:
  30. external: false
  31. services:
  32. server:
  33. image: gitea/gitea:latest
  34. restart: always
  35. networks:
  36. - gitea
  37. volumes:
  38. - ./gitea:/data
  39. ports:
  40. - "3000:3000"
  41. - "222:22"
  42. ```
  43. ## Custom port
  44. To bind the integrated openSSH daemon and the webserver on a different port, adjust
  45. the port section. It's common to just change the host port and keep the ports within
  46. the container like they are.
  47. ```diff
  48. version: "2"
  49. networks:
  50. gitea:
  51. external: false
  52. services:
  53. server:
  54. image: gitea/gitea:latest
  55. restart: always
  56. networks:
  57. - gitea
  58. volumes:
  59. - ./gitea:/data
  60. ports:
  61. - - "3000:3000"
  62. - - "222:22"
  63. + - "8080:3000"
  64. + - "2221:22"
  65. ```
  66. ## MySQL database
  67. To start Gitea in combination with a MySQL database, apply these changes to the
  68. `docker-compose.yml` file created above.
  69. ```diff
  70. version: "2"
  71. networks:
  72. gitea:
  73. external: false
  74. services:
  75. server:
  76. image: gitea/gitea:latest
  77. restart: always
  78. networks:
  79. - gitea
  80. volumes:
  81. - ./gitea:/data
  82. ports:
  83. - "3000:3000"
  84. - "222:22"
  85. + depends_on:
  86. + - db
  87. +
  88. + db:
  89. + image: mysql:5.7
  90. + restart: always
  91. + environment:
  92. + - MYSQL_ROOT_PASSWORD=gitea
  93. + - MYSQL_USER=gitea
  94. + - MYSQL_PASSWORD=gitea
  95. + - MYSQL_DATABASE=gitea
  96. + networks:
  97. + - gitea
  98. + volumes:
  99. + - ./mysql:/var/lib/mysql
  100. ```
  101. ## PostgreSQL database
  102. To start Gitea in combination with a PostgreSQL database, apply these changes to
  103. the `docker-compose.yml` file created above.
  104. ```diff
  105. version: "2"
  106. networks:
  107. gitea:
  108. external: false
  109. services:
  110. server:
  111. image: gitea/gitea:latest
  112. restart: always
  113. networks:
  114. - gitea
  115. volumes:
  116. - ./gitea:/data
  117. ports:
  118. - "3000:3000"
  119. - "222:22"
  120. + depends_on:
  121. + - db
  122. +
  123. + db:
  124. + image: postgres:9.6
  125. + restart: always
  126. + environment:
  127. + - POSTGRES_USER=gitea
  128. + - POSTGRES_PASSWORD=gitea
  129. + - POSTGRES_DB=gitea
  130. + networks:
  131. + - gitea
  132. + volumes:
  133. + - ./postgres:/var/lib/postgresql/data
  134. ```
  135. ## Named volumes
  136. To use named volumes instead of host volumes, define and use the named volume
  137. within the `docker-compose.yml` configuration. This change will automatically
  138. create the required volume.
  139. ```diff
  140. version: "2"
  141. networks:
  142. gitea:
  143. external: false
  144. +volumes:
  145. + gitea:
  146. + driver: local
  147. +
  148. services:
  149. server:
  150. image: gitea/gitea:latest
  151. restart: always
  152. networks:
  153. - gitea
  154. volumes:
  155. - - ./gitea:/data
  156. + - gitea:/data
  157. ports:
  158. - "3000:3000"
  159. - "222:22"
  160. ```
  161. MySQL or PostgreSQL containers will need to be created separately.
  162. ## Start
  163. To start this setup based on `docker-compose`, execute `docker-compose up -d`,
  164. to launch Gitea in the background. Using `docker-compose ps` will show if Gitea
  165. started properly. Logs can be viewed with `docker-compose logs`.
  166. To shut down the setup, execute `docker-compose down`. This will stop
  167. and kill the containers. The volumes will still exist.
  168. Notice: if using a non-3000 port on http, change app.ini to match
  169. `LOCAL_ROOT_URL = http://localhost:3000/`.
  170. ## Install
  171. After starting the Docker setup via `docker-compose` Gitea should be available using a
  172. favorite browser to finalize the installation. Visit http://server-ip:3000 and follow the
  173. installation wizard. If the database was started with the `docker-compose` setup as
  174. documented above please note that `db` must be used as the database hostname.
  175. # Customization
  176. Customization files described [here](https://docs.gitea.io/en-us/customizing-gitea/) should
  177. be placed in `/data/gitea` directory. If using host volumes it's quite easy to access these
  178. files; for named volumes this is done through another container or by direct access at
  179. `/var/lib/docker/volumes/gitea_gitea/_data`. The configuration file will be saved at
  180. `/data/gitea/conf/app.ini` after the installation.