I am trying to clone a Git repository from a self-hosted GitLab instance that is running on a custom port 6022, but I am unable to do so. Here’s what I’ve tried so far:
-
I have confirmed that the GitLab instance is up and running on port 6022 by checking it with terminal command lsof, netstat, etc.
-
I have created an SSH key and added it to my GitLab account.
-
I have tried to clone the repository using the SSH URL provided by
GitLab, like this:git clone [email protected]:6022/my-username/my-repo.git
-
I have also tried to specify the custom port using the -p flag, like this:
git clone -p 6022 [email protected]:my-username/my-repo.git
However, both of these methods result in the following error:
Copy code
Cloning into 'my-repo'...
ssh: connect to host mygitlabinstance.com port 6022: Connection refused
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
how can I clone the repository from my self-hosted GitLab instance on port 6022?
this is my docker-compose.yml
version: '3.7'
services:
web:
image: 'gitlab/gitlab-ee:latest'
restart: always
hostname: 'gitlab.example.com'
container_name: gitlab-ee
environment:
GITLAB_OMNIBUS_CONFIG: |
#external_url 'https://gitlab.example.com'
#external_url 'http://localhost:80'
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "***"
gitlab_rails['smtp_port'] = 587
gitlab_rails['smtp_user_name'] = "developer@*.com"
gitlab_rails['smtp_password'] = "**"
gitlab_rails['smtp_domain'] = "**.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = false
gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
gitlab_rails['gitlab_shell_ssh_port'] = 6022
nginx['redirect_http_to_https'] = true
nginx['ssl_certificate'] = "/etc/gitlab/ssl/fullchain.pem"
nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/privkey.pem"
nginx['ssl_dhparam'] = "/etc/gitlab/ssl/dhparams.pem"
# HTTPS Setup
#letsencrypt['enable'] = false
#external_url 'https://gitlab.example.com'
#gitlab_rails['gitlab_https'] = true
#gitlab_rails['gitlab_port'] = 443
ports:
- '8081:80'
- '8443:443'
- '6022:22'
- '587:587'
volumes:
- '$GITLAB_HOME/config:/etc/gitlab'
- '$GITLAB_HOME/logs:/var/log/gitlab'
- '$GITLAB_HOME/data:/var/opt/gitlab'
- '$GITLAB_HOME/config/ssl:/etc/gitlab/ssl'
#networks:
2
Answers
Solved the problem that I need to open the port on the cloud service settings in my case
Alibaba Cloud
. I need to add updest 6022/6022
on the port setup.If you map the host port 6022 to the container port 22, that means you expect SSH inside the container to answer to port 22 (which is expected, as it is the default port).
However, your Omnibus GitLab instance running inside that container is instructed to set public SSH URL using port 6022, as documented in "Expose GitLab on different ports".
That means an URL like this should work, as described in this thread: