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?

  • Docker client certificate issue
  • how do i run a container so that it is running behind a proxy + on running?
  • How to load docker image from tar file
  • wordpress container cannot connect to mariadb container
  • Running docker shell on Windows
  • portforwarding from within docker container
  • Docker and node_modules - put them in a layer, or a volume?
  • Run `docker-php-ext-install` FROM container other than php
  • Is there a way to get the Docker Hub username of the current user?
  • Dokku Buil Failed - Pre-receive hook declined
  • How do you get a file from a windows host to linux docker container?
  • How can my friend and I share an exact development environment together while on different operating systems?
  • 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.