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
git add
git commmit -m "How do I get this into Gogs"

How do I now migrate / push this to Gogs?

  • Unable to create docker virtual machine
  • Docker workflow for development- running containers build up
  • Extend Existing Docker Image
  • Install Docker script error - permission denied
  • Is all WSO2 API Manager's configuration saved in the database?
  • Docker Java 8 Container with Heavy CPU Usage
  • Seeding a MySQL DB for a Dockerized Django App
  • Dockerized Mongo takes ages to load then doesn't run mongo
  • sources: where daemon call libcontainer in createContainer
  • Why is this docker image allowed past the firewall?
  • How to overlay a particular folder in one project into the same folder on other projects
  • How to bind a shared directory from container to host in Docker
  • 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.