{"action":"created","issue":{"url":"https://api.github.com/repos/gogits/gogs/issues/1788","labels_url":"https://api.github.com/repos/gogits/gogs/issues/1788/labels{/name}","comments_url":"https://api.github.com/repos/gogits/gogs/issues/1788/comments","events_url":"https://api.github.com/repos/gogits/gogs/issues/1788/events","html_url":"https://github.com/gogits/gogs/issues/1788","id":111576892,"number":1788,"title":"SSH doesn't work on ports other than 22 in dockerized gogs","user":{"login":"simonacca","id":1206381,"avatar_url":"https://avatars.githubusercontent.com/u/1206381?v=3","gravatar_id":"","url":"https://api.github.com/users/simonacca","html_url":"https://github.com/simonacca","followers_url":"https://api.github.com/users/simonacca/followers","following_url":"https://api.github.com/users/simonacca/following{/other_user}","gists_url":"https://api.github.com/users/simonacca/gists{/gist_id}","starred_url":"https://api.github.com/users/simonacca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simonacca/subscriptions","organizations_url":"https://api.github.com/users/simonacca/orgs","repos_url":"https://api.github.com/users/simonacca/repos","events_url":"https://api.github.com/users/simonacca/events{/privacy}","received_events_url":"https://api.github.com/users/simonacca/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-10-15T09:23:09Z","updated_at":"2015-10-15T10:48:18Z","closed_at":null,"body":"Trying to changed the docker ssh port from default to 2222 in a dockerized environment doesn't work as expected.\r\n\r\n### Steps to reproduce:\r\n1) Bring up a gogs container with the following docker-compose config:\r\n```\r\ngogs:\r\n  image: gogs/gogs\r\n  ports:\r\n    - \"10080:10080\"\r\n    - \"2222:2222\"\r\n  volumes:\r\n    - \"/var/gogs/data:/data\"\r\n``` \r\n\r\n2) change the config file in: `/var/gogs/data/gogs/conf/app.ini` as follow:\r\n```\r\n[server]\r\nDOMAIN = git.mydomain.com\r\nHTTP_PORT = 10080\r\nROOT_URL = http://git.mydomain.com\r\nDISABLE_SSH = false\r\nSSH_PORT = 2222\r\nOFFLINE_MODE = false\r\n```\r\n\r\n3) \r\n\r\n* create a repo (let's say myuser/myrepo) \r\n* the gogs interface will give you this address, which is correct: `ssh://git@git.mydomain.com:2222/myuser/myrepo.git`\r\n* push some content from a local repo:\r\n  * `git remote add origin ssh://git@git.mydomain.com:2222/myuser/myrepo.git`\r\n  * `git push -u origin master`\r\n\r\nIn pushing, you will get this error:\r\n```\r\nssh: connect to host git.mydomain.com port 2222: Connection refused\r\nfatal: Could not read from remote repository.\r\n\r\nPlease make sure you have the correct access rights\r\nand the repository exists.\r\n\r\n```\r\n\r\n### Additional info:\r\n\r\n* The UI says: Version 0.6.16.1008 Beta\r\n* I tried this on 2 machines with identical results.\r\n\r\n### Workaround\r\n\r\nA temporary solution is to use the port `22` inside the container and map it with  `-p 2222:22`.\r\n\r\nThis **is suboptimal** since the urls generated by the UI will be wrong, in this case the url would have been `git@git.mydomain.com:cnb/scraper.git`, which is *incorrect*."},"comment":{"url":"https://api.github.com/repos/gogits/gogs/issues/comments/148349485","html_url":"https://github.com/gogits/gogs/issues/1788#issuecomment-148349485","issue_url":"https://api.github.com/repos/gogits/gogs/issues/1788","id":148349485,"user":{"login":"tboerger","id":156964,"avatar_url":"https://avatars.githubusercontent.com/u/156964?v=3","gravatar_id":"","url":"https://api.github.com/users/tboerger","html_url":"https://github.com/tboerger","followers_url":"https://api.github.com/users/tboerger/followers","following_url":"https://api.github.com/users/tboerger/following{/other_user}","gists_url":"https://api.github.com/users/tboerger/gists{/gist_id}","starred_url":"https://api.github.com/users/tboerger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tboerger/subscriptions","organizations_url":"https://api.github.com/users/tboerger/orgs","repos_url":"https://api.github.com/users/tboerger/repos","events_url":"https://api.github.com/users/tboerger/events{/privacy}","received_events_url":"https://api.github.com/users/tboerger/received_events","type":"User","site_admin":false},"created_at":"2015-10-15T10:48:18Z","updated_at":"2015-10-15T10:48:18Z","body":"Please read my comment again. It's not exactly like you have written. The value within the gogs config is just for displaying the SSH port, so set it to 2222, map the publish attribute of docker still to 22 within the container and everything works like it should be."}}