[!NOTE] This is the next-generation, security-focused Docker image. This will become the default image distribution (
gogs/gogs:latest) starting 0.15.0.
Visit Docker Hub or GitHub Container registry to see all available images and tags.
This Docker image is designed with Kubernetes security best practices in mind:
gogs websecurityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
allowPrivilegeEscalation: false
seccompProfile:
type: RuntimeDefault
capabilities:
drop:
- ALL
If you need a different UID/GID, build the image with custom arguments:
docker build -f Dockerfile.next --build-arg GOGS_UID=1001 --build-arg GOGS_GID=1001 -t my-gogs .
$ docker pull gogs/gogs:next-latest
# Create local directory for volume.
$ mkdir -p /var/gogs
$ chown 1000:1000 /var/gogs
# Use `docker run` for the first time.
$ docker run --name=gogs -p 10022:2222 -p 10880:3000 -v /var/gogs:/data gogs/gogs:next-latest
# Use `docker start` if you have stopped it.
$ docker start gogs
Files will be stored in local path /var/gogs.
Directory /var/gogs keeps Git repositories and Gogs data:
/var/gogs
|-- git
|-- gogs-repositories
|-- gogs
|-- conf
|-- data
|-- log
|-- ssh
$ docker volume create --name gogs-data
$ docker run --name=gogs -p 10022:2222 -p 10880:3000 -v gogs-data:/data gogs/gogs:next-latest
Most of the settings are obvious and easy to understand, but there are some settings can be confusing by running Gogs inside Docker:
/home/git/gogs-repositoriesgit (UID 1000)192.168.99.100). But if you want to access your Gogs instance from a different physical machine, please fill in with the hostname or IP address of the Docker host machine.2222 inside Docker, but you expose it by 10022:2222, then use 10022 for this value.3000 inside Docker, and you expose it by 10880:3000, but you still use 3000 for this value.http://192.168.99.100:10880/).Full documentation of application settings can be found in the default app.ini.
[!IMPORTANT] Enable and disable of the builtin SSH server requires restart of the container to take effect.
To enable Git over SSH access, the use of builtin SSH server is required as follows in your app.ini:
[server]
START_SSH_SERVER = true
SSH_PORT = 10022 # The port shown in the clone URL
SSH_LISTEN_PORT = 2222 # The port that builtin server listens on
[!CAUTION] Make sure you have volumed data to somewhere outside Docker container!
Steps to upgrade Gogs with Docker:
docker pull gogs/gogs:next-latestdocker stop gogsdocker rm gogs