Adding a Local GIT Repository to a Gogs Docker Container

I’ve installed Gogs using Docker. Subsequently I have created a local repository like this (In reality the repository has multiple branches, etc. but I’m just keeping this example simple):

mkdir repository
cd repository
git init
touch README.md
git add README.md
git commmit -m "How do I get this into Gogs"

How do I now migrate / push this to Gogs?

  • Pull, virtualize, and bash into a docker image
  • kubernetes how to set the maximum size of the log file?
  • Error response from daemon: Get https://x.x.x.x/v1/users/: x509: certificate signed by unknown authority
  • Why is nginx returning a 502 when doing a `uwsgi_pass` to a linked docker container?
  • artifactory as docker registry
  • File ownership on building docker images
  • Docker-compose: Database is uninitialized
  • How to fill in a Docker mongodb image
  • How can i keep crontab in file in ubuntu docker
  • Can docker application use dependent images?
  • Is it possible to run match servers on Kubernetes for a Real Time Multiplayer game?
  • Docker linking works on one host but not another
  • One Solution collect form web for “Adding a Local GIT Repository to a Gogs Docker Container”

    To push changesets to gogs, you’ll need to create a repo on gogs then add a remote that uses the port exposed when the container was started. If you’re unsure, run the following and note the HostPort entries. Assuming the container is named gogs:

    docker inspect  --format "{{json .HostConfig.PortBindings}}" gogs
    

    The following are steps to set up an ssh remote origin.
    Add your public key using the gogs web ui accessed by the HostPort entry for 3000/tcp. If you followed the gogs docker instructions, this will likely be: http://localhost:10080 If gogs is not running locally, replace localhost with the gogs hostname.

    Add the following host entry to ~/.ssh/config to more easily specify an alternate ssh port:

    Host gogs
        # if gogs is not running locally, add the remote hostname here
        Hostname localhost
        User git
        # the following should match what is listed for HostPort 22/tcp
        port 10022
    

    Test the ssh host entry with ssh gogs. If it works you should see:

    PTY allocation request failed on channel 0
    Hi there, You've successfully authenticated, but Gogs does not provide shell access.
    If this is unexpected, please log in with password and setup Gogs under another user.
    Connection to localhost closed.
    

    Add the following as your remote:

    git remote add origin gogs:yourusername/your-repo.git
    

    Note that you’re replacing git@localhost with the gogs ssh host entry.

    You should now be able to push to your gogs repo.

    Docker will be the best open platform for developers and sysadmins to build, ship, and run distributed applications.