Gogs in Docker git clone woes


#1

I’ve read other answers to issues trying to do an SSH clone with Gogs and attempted to apply suggested fixes all to no avail. What makes this a bit different is the way I’m doing things.

My GOGS is a container in Docker (I used docker-compose to build it) and here is the compose file I am using for the curious.

version: "3"
services:
  gogs:
    hostname: git
    domainname: berghold.net
    build: gogs
    restart: always
    networks:
      middleware:
        ipv4_address: 172.50.10.100
      backend:
        ipv4_address: 172.50.20.151
    ports:
      - "9024:22"
      - "3000:3000"
    volumes:
   - /data:/data
  gogs_db:
     hostname: gogs-db
     domainname: docker.berghold.net
     image: local-mariadb:latest
     build: gogs-db
     volumes:
       - gogs_db_data:/var/lib/mysql
     networks:
       backend:
         ipv4_address: 172.50.20.150
     restart: always
     environment:
       MYSQL_ROOT_PASSWORD: <redacted>
       MYSQL_DATABASE: <censored>
       MYSQL_USER: gogs
       MYSQL_PASSWORD: <nopeitsasecret>

   
volumes:
  gogs_db_data:

networks:
  middleware:
    external:
     name: "middleware"
  backend:
    external:
      name: "backend"

One reason I’m bothering post that is note the mapping for the SSH port for the gogs engine itself. I’ve got the host port 9024 mapped to the container port 22. I made sure my front end firewall is passing 9024 into the container and so far as I can tell it is.

I tried cloning with HTTP and all is hunky-dory but I do not want to use HTTP (in fact I’m considering disabling HTTP) I want to use SSH. Ultimately Jenkins is going to be talking to the repositories on this host.

So I try SSH thusly:

$ git  clone git@git.berghold.net:9024/peter/testapp.git
Cloning into 'testapp'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

well… that didn’t work. Previously I uploaded my keys to Gogs that work fine on BitBucket (want to move from there) with all my repos there.

I guess my question is there something special I need to do to make it work within Docker?

The Gogs Docker image was built from gogs/gogs:latest.


#2

Hi, if you 100% believe the SSH request has arrived the Docker container runs Gogs, read part 1 of How to config SSH settings.

It works only proved you have a valid public key, but that’s all it means.

I’m like ->


#3

Let’s make an assumption that it is not. Is there some sort of logging I can turn on in Gog that would either prove that it is?

bill-the-cat-ack


#4

It is matter that handles by OpenSSH server, the request not even reached to Gogs yet.


#5

The issue was with the URL. The URL that Gogs supplies is actually wrong.

What Gogs supplied was: git@git.berghold.net:peter/testapp.git

I used: git@git.berghold.net:9024/peter/testapp.git

What it should be is: ssh://git@git.berghold.net:9024/peter/testapp.git

Works well… lasts a long time. (I hope)


#6

Just to do penance I’m going to write up a “how to” on my blog to expand on the existing one dealing with how to deploy Gogs to a docker container.

shipping-container


#7

Gogs will generate this URL if you tells the Gogs the port is 9024 in the installation page.


#8

If that’s the case where in the config file do you set that. Almost afraid to mess with it I broke stuff last time…


#9

Here you go: https://github.com/gogs/gogs/blob/a1098384c09bc0d569ec82d19c26415e00cc364b/conf/app.ini#L30-L31