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?

  • When running Docker on Raspberry Pi starting containers fails from time to time
  • Monolithic (vs) Micro-services ==> Threads (vs) Process
  • Windows container fails to reach Azure File Storage
  • How does device mapper “union” docker images
  • how does Flocker implement image migration while doing container migration between hosts
  • Why does `apt install postgresql` not work in a docker container?
  • AWS EB deployment - where is my app?
  • How can I make Atifactory docker registry images use docker manifest version 2?
  • cant connect to docker daemon - eclipse che
  • building oracle docker image on mac os x fails with “This system does not meet the minimum requirements for swap space.”
  • Docker REST API is not binding on port for Jenkins
  • Send a wake on lan packet from a docker container
  • 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.