Skip to content

Instantly share code, notes, and snippets.

@bst27
Created November 19, 2023 12:36
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bst27/1b5d43317e50183320e0e094d1e4f7fc to your computer and use it in GitHub Desktop.
Save bst27/1b5d43317e50183320e0e094d1e4f7fc to your computer and use it in GitHub Desktop.
Gitea docker (rootless) without SSH Passthrough

Gitea docker (rootless) without SSH passthrough

Official gitea docs are heavily focussed on doing SSH passthrough from the host machine to the docker container. An alternative is to simply run SSH for Gitea on a different port. Though I had some problems getting this docker compose setup to run. This gist contains my setup I finally came up with: It does not require SSH passthrough from the host to the docker container but still offers support to git clone via SSH.

To check if this setup works for you simply follow these steps:

  1. Place enclosed docker-compose.yml in a directory.
  2. Run docker compose up
  3. Visit http://localhost:8033/ and simply install Gitea with given defaults
  4. Visit http://localhost:8033/user/sign_up and create user account with username example
  5. Visit http://localhost:8033/user/settings/keys and add your SSH key
  6. Visit http://localhost:8033/repo/create and create repository with test name
  7. Clone repository using ssh://git@localhost:8034/example/test.git
  8. In the previous step you should be authenticated automatically with your SSH key and get a clone of the empy git repository
  9. Use this working setup as a base to customize for your needs.

References

version: "3"
services:
server:
image: gitea/gitea:1.21.0-rootless
container_name: gitea
environment:
- GITEA__server__START_SSH_SERVER=true
- GITEA__server__SSH_PORT=8034
- GITEA__server__ROOT_URL=http://localhost:8033/
restart: unless-stopped
volumes:
- gitea-data:/var/lib/gitea
- gitea-config:/etc/gitea
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
ports:
- "8033:3000" # webinterface
- "8034:2222" # ssh
volumes:
gitea-data:
gitea-config:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment