[root@fieldyang01 data]# docker run -it --name=gogs -p 3022:22 -p 3000:3000 -v /root/yangzw/docker/gogs/data:/data gogs/gogs
Unable to find image 'gogs/gogs:latest' locally
Trying to pull repository docker.io/gogs/gogs ...
latest: Pulling from docker.io/gogs/gogs
4167d3e14976: Already exists
704e829dff56: Pull complete
5587acc07e36: Pull complete
601ee68e0a52: Pull complete
bf08e966ad0d: Pull complete
e7b15b521d7a: Pull complete
fb4923e8a346: Pull complete
ff67ac8dc117: Pull complete
Digest: sha256:11881ec83a493019abcec7db21a12e1bcce19cdc04f2efd04170f1a3a2815c91
Status: Downloaded newer image for docker.io/gogs/gogs:latest
usermod: no changes
Mar 11 14:39:54 syslogd started: BusyBox v1.30.1
Mar 11 14:39:55 sshd[36]: Server listening on :: port 22.
Mar 11 14:39:55 sshd[36]: Server listening on 0.0.0.0 port 22.
2020/03/11 14:39:57 [ WARN] Custom config "/data/gogs/conf/app.ini" not found. Ignore this warning if you're running for the first time
2020/03/11 14:39:57 [TRACE] Log mode: Console (Trace)
2020/03/11 14:39:57 [ INFO] Gogs 0.12.0+dev
2020/03/11 14:39:57 [TRACE] Work directory: /app/gogs
2020/03/11 14:39:57 [TRACE] Custom path: /data/gogs
2020/03/11 14:39:57 [TRACE] Custom config: /data/gogs/conf/app.ini
2020/03/11 14:39:57 [TRACE] Log path: /app/gogs/log
2020/03/11 14:39:57 [TRACE] Build time: 2020-03-10 07:07:54 UTC
2020/03/11 14:39:57 [TRACE] Build commit: 434f1ec542cc6dab6b2709e3a6fab261bdad4c7b
2020/03/11 14:39:57 [ INFO] SQLite3 is supported
2020/03/11 14:39:57 [ INFO] Run mode: Development
2020/03/11 14:39:57 [ INFO] Listen on http://0.0.0.0:3000
[root@fieldyang01 nginx]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f2bbb060b89e gogs/gogs "/app/gogs/docker/..." 48 seconds ago Up 47 seconds 0.0.0.0:3000->3000/tcp, 0.0.0.0:3022->22/tcp gogs
6ffb685c8e91 mysql:5.6 "docker-entrypoint..." 46 hours ago Up 46 hours 3306/tcp db01
aa658f0d7269 centos:6.8 "/bin/bash" 4 days ago Exited (255) 3 days ago centos
f21ba87f00f9 ubuntu:14.04 "/bin/bash" 4 days ago Exited (0) 4 days ago ubuntu
[root@fieldyang01 nginx]# docker exec -it f2bbb060b89e sh
/app/gogs # ifconfig
eth0 Link encap:Ethernet HWaddr 02:42:AC:11:00:02
inet addr:172.17.0.2 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::42:acff:fe11:2/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:648 (648.0 B) TX bytes:648 (648.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
/app/gogs #
[root@fieldyang01 nginx]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3a2a62fa9215 nginx:alpine "nginx -g 'daemon ..." 12 seconds ago Up 10 seconds 0.0.0.0:1080->80/tcp nginx
f2bbb060b89e gogs/gogs "/app/gogs/docker/..." 2 minutes ago Up 2 minutes 0.0.0.0:3000->3000/tcp, 0.0.0.0:3022->22/tcp gogs
6ffb685c8e91 mysql:5.6 "docker-entrypoint..." 46 hours ago Up 46 hours 3306/tcp db01
aa658f0d7269 centos:6.8 "/bin/bash" 4 days ago Exited (255) 3 days ago centos
f21ba87f00f9 ubuntu:14.04 "/bin/bash" 4 days ago Exited (0) 4 days ago ubuntu
[root@fieldyang01 nginx]# docker exec -it 3a2a62fa9215 sh
/ # ifconfig
eth0 Link encap:Ethernet HWaddr 02:42:AC:11:00:04
inet addr:172.17.0.4 Bcast:0.0.0.0 Mask:255.255.0.0
inet6 addr: fe80::42:acff:fe11:4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:8 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:648 (648.0 B) TX bytes:648 (648.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
/ #
[root@fieldyang01 nginx]# cat gogs.conf
server
{
listen 80;
server_name 172.17.0.4;
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://172.17.0.2:3000;
}
}
[root@fieldyang01 nginx]#
[root@fieldyang01 nginx]# cat > gogs.conf
server
{
listen 80;
server_name 172.17.0.4;
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://172.17.0.2:3000;
}
}
[root@fieldyang01 nginx]# docker stop nginx
nginx
[root@fieldyang01 nginx]# docker start nginx
nginx
[root@fieldyang01 nginx]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3a2a62fa9215 nginx:alpine "nginx -g 'daemon ..." About a minute ago Up 5 seconds 0.0.0.0:1080->80/tcp nginx
f2bbb060b89e gogs/gogs "/app/gogs/docker/..." 3 minutes ago Up 3 minutes 0.0.0.0:3000->3000/tcp, 0.0.0.0:3022->22/tcp gogs
6ffb685c8e91 mysql:5.6 "docker-entrypoint..." 46 hours ago Up 46 hours 3306/tcp db01
aa658f0d7269 centos:6.8 "/bin/bash" 4 days ago Exited (255) 3 days ago centos
f21ba87f00f9 ubuntu:14.04 "/bin/bash" 4 days ago Exited (0) 4 days ago
访问 192.168.2.111:1080 会重定向到 安装页面Gogs
如果您正在使用 Docker 容器运行 Gogs,请务必先仔细阅读 官方文档 后再对本页面进行填写。
[root@fieldyang01 nginx]# wget 127.0.0.1:1080
--2020-03-11 11:04:42-- http://127.0.0.1:1080/
Connecting to 127.0.0.1:1080... connected.
HTTP request sent, awaiting response... 302 Found
Location: /install [following]
--2020-03-11 11:04:42-- http://127.0.0.1:1080/install
Reusing existing connection to 127.0.0.1:1080.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html.1’
[ <=> ] 17,642 --.-K/s in 0s
2020-03-11 11:04:42 (227 MB/s) - ‘index.html.1’ saved [17642]
[root@fieldyang01 nginx]# wget 192.168.2.111:1080
--2020-03-11 11:04:54-- http://192.168.2.111:1080/
Connecting to 192.168.2.111:1080... connected.
HTTP request sent, awaiting response... 302 Found
Location: /install [following]
--2020-03-11 11:04:54-- http://192.168.2.111:1080/install
Reusing existing connection to 192.168.2.111:1080.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html.2’
[ <=> ] 17,642 --.-K/s in 0s
2020-03-11 11:04:54 (157 MB/s) - ‘index.html.2’ saved [17642]
[root@fieldyang01 nginx]# ls -lrt
total 64
-rw-r--r--. 1 root root 262 Mar 11 10:52 gogs.conf
-rw-r--r--. 1 root root 17642 Mar 11 11:04 index.html
-rw-r--r--. 1 root root 17642 Mar 11 11:04 index.html.1
-rw-r--r--. 1 root root 17642 Mar 11 11:04 index.html.2
[root@fieldyang01 nginx]#
[root@fieldyang01 data]# docker run -it --name=gogs -p 3022:22 -p 3000:3000 -v /root/yangzw/docker/gogs/data:/data gogs/gogs
usermod: no changes
Mar 11 14:57:56 syslogd started: BusyBox v1.30.1
Mar 11 14:57:56 sshd[31]: Server listening on :: port 22.
Mar 11 14:57:56 sshd[31]: Server listening on 0.0.0.0 port 22.
2020/03/11 14:57:57 [ WARN] Custom config "/data/gogs/conf/app.ini" not found. Ignore this warning if you're running for the first time
2020/03/11 14:57:57 [TRACE] Log mode: Console (Trace)
2020/03/11 14:57:57 [ INFO] Gogs 0.12.0+dev
2020/03/11 14:57:57 [TRACE] Work directory: /app/gogs
2020/03/11 14:57:57 [TRACE] Custom path: /data/gogs
2020/03/11 14:57:57 [TRACE] Custom config: /data/gogs/conf/app.ini
2020/03/11 14:57:57 [TRACE] Log path: /app/gogs/log
2020/03/11 14:57:57 [TRACE] Build time: 2020-03-10 07:07:54 UTC
2020/03/11 14:57:57 [TRACE] Build commit: 434f1ec542cc6dab6b2709e3a6fab261bdad4c7b
2020/03/11 14:57:57 [ INFO] SQLite3 is supported
2020/03/11 14:57:57 [ INFO] Run mode: Development
2020/03/11 14:57:57 [ INFO] Listen on http://0.0.0.0:3000
访问 192.168.2.11:1080页面
日志:
...
2020/03/11 15:02:31 [TRACE] Session ID: 2cb7c1414d91b51e
2020/03/11 15:02:31 [TRACE] CSRF Token: DcUEAM60Qgqp42L_QwUsLe4mIsY6MTU4MzkzODk1MTU3MDM4NTYxOA
2020/03/11 15:02:31 [TRACE] Session ID: 2cb7c1414d91b51e
2020/03/11 15:02:31 [TRACE] CSRF Token: DcUEAM60Qgqp42L_QwUsLe4mIsY6MTU4MzkzODk1MTU3MDM4NTYxOA
2020/03/11 15:02:31 [TRACE] Template: install
2020/03/11 15:02:46 [TRACE] Session ID: 2cb7c1414d91b51e
2020/03/11 15:02:46 [TRACE] CSRF Token: DcUEAM60Qgqp42L_QwUsLe4mIsY6MTU4MzkzODk1MTU3MDM4NTYxOA
2020/03/11 15:02:46 [TRACE] Template: install
2020/03/11 15:03:15 [TRACE] Session ID: 2cb7c1414d91b51e
2020/03/11 15:03:15 [TRACE] CSRF Token: DcUEAM60Qgqp42L_QwUsLe4mIsY6MTU4MzkzODk1MTU3MDM4NTYxOA
2020/03/11 15:03:15 [TRACE] Template: install
2020/03/11 15:04:02 [TRACE] Session ID: 053b71175c97e9e7
2020/03/11 15:04:02 [TRACE] CSRF Token: Azj4SGRmC2gNF4qwtpq3BwYqaKc6MTU4MzkzOTA0MjUwNTI0MzI2OA
2020/03/11 15:04:15 [TRACE] Session ID: e3bf8904df28d056
2020/03/11 15:04:15 [TRACE] CSRF Token: oXsofY9uq-CA1iKLhu-YQ7b6C7c6MTU4MzkzOTA1NTI5OTA0MTEwMw
2020/03/11 15:04:15 [TRACE] Session ID: e3bf8904df28d056
2020/03/11 15:04:15 [TRACE] CSRF Token: oXsofY9uq-CA1iKLhu-YQ7b6C7c6MTU4MzkzOTA1NTI5OTA0MTEwMw
2020/03/11 15:04:15 [TRACE] Template: install
2020/03/11 15:04:42 [TRACE] Session ID: c02f6ec1c56424e1
2020/03/11 15:04:42 [TRACE] CSRF Token: iBLoPp_5Ga1RECxJnmfSEtfqC5k6MTU4MzkzOTA4MjM4NTMzNTk1Nw
2020/03/11 15:04:42 [TRACE] Session ID: c02f6ec1c56424e1
2020/03/11 15:04:42 [TRACE] CSRF Token: iBLoPp_5Ga1RECxJnmfSEtfqC5k6MTU4MzkzOTA4MjM4NTMzNTk1Nw
2020/03/11 15:04:42 [TRACE] Template: install
2020/03/11 15:04:54 [TRACE] Session ID: d42a7a84a02867ad
2020/03/11 15:04:54 [TRACE] CSRF Token: CVevz9af7evagW6t3pNMurlalnY6MTU4MzkzOTA5NDY1NjU4NjQ5NA
2020/03/11 15:04:54 [TRACE] Session ID: d42a7a84a02867ad
2020/03/11 15:04:54 [TRACE] CSRF Token: CVevz9af7evagW6t3pNMurlalnY6MTU4MzkzOTA5NDY1NjU4NjQ5NA
2020/03/11 15:04:54 [TRACE] Template: install
2020/03/11 15:05:40 [TRACE] Session ID: d5a2367aa3d3cf74
2020/03/11 15:05:40 [TRACE] CSRF Token: NqqSVh2haPjqMfoJd9TGnRk9F4o6MTU4MzkzOTE0MDcxMjAzMzc1MA
2020/03/11 15:05:40 [TRACE] Session ID: d5a2367aa3d3cf74
2020/03/11 15:05:40 [TRACE] CSRF Token: NqqSVh2haPjqMfoJd9TGnRk9F4o6MTU4MzkzOTE0MDcxMjAzMzc1MA
2020/03/11 15:05:40 [TRACE] Template: install
2020/03/11 15:07:24 [TRACE] Session ID: 2cb7c1414d91b51e
2020/03/11 15:07:24 [TRACE] CSRF Token: DcUEAM60Qgqp42L_QwUsLe4mIsY6MTU4MzkzODk1MTU3MDM4NTYxOA
2020/03/11 15:07:24 [TRACE] Template: install
2020/03/11 15:07:37 [TRACE] Session ID: 2cb7c1414d91b51e
2020/03/11 15:07:37 [TRACE] CSRF Token: DcUEAM60Qgqp42L_QwUsLe4mIsY6MTU4MzkzODk1MTU3MDM4NTYxOA
2020/03/11 15:07:37 [TRACE] Template: install
2020/03/11 15:07:41 [TRACE] Session ID: 2cb7c1414d91b51e
2020/03/11 15:07:41 [TRACE] CSRF Token: DcUEAM60Qgqp42L_QwUsLe4mIsY6MTU4MzkzODk1MTU3MDM4NTYxOA
2020/03/11 15:07:41 [TRACE] Template: install
2020/03/11 15:07:43 [TRACE] Session ID: 2cb7c1414d91b51e
2020/03/11 15:07:43 [TRACE] CSRF Token: DcUEAM60Qgqp42L_QwUsLe4mIsY6MTU4MzkzODk1MTU3MDM4NTYxOA
2020/03/11 15:07:43 [TRACE] Template: install