How do I rebuild app using the host network rather than the docker network?


Sometimes when I perform upgrades via the web UI, discourse tells me to run

cd /var/discourse
git pull
./launcher rebuild app

Since the rebuild process connects to github several times and github is half-blocked in China, where my server is hosted, I have to setup http/https proxy to better access github. Here is a comparison between visiting youtube w/o proxy and w/ proxy:

root@iosre:/var/discourse# wget
--2021-06-10 23:55:05--
Resolving (, 2001::3d6f:fadc
Connecting to (||:443... ^C
root@iosre:/var/discourse# export https_proxy= http_proxy= all_proxy=socks5://
root@iosre:/var/discourse# wget
--2021-06-10 23:56:12--
Connecting to connected.
Proxy request sent, awaiting response... 301 Moved Permanently
Location: [following]
--2021-06-10 23:56:13--
Connecting to connected.
Proxy request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: ‘index.html’

index.html [  <=>  ] 510.58K   813KB/s    in 0.6s    

2021-06-10 23:56:14 (813 KB/s) - ‘index.html’ saved [522830]

However when I run ./launcher rebuild image, the script will enter the app and perform all operations inside the docker, where the network environment is different from the proxied host, and I’m not able to access youtube, so rebuild will fail most of the time.

root@iosre:/var/discourse# ./launcher enter app
root@iosre-app:/var/www/discourse# wget
--2021-06-10 15:59:57--
Resolving (, 2001::d238:33c1
Connecting to (||:443... ^C
root@iosre-app:/var/www/discourse# export https_proxy= http_proxy= all_proxy=socks5://
root@iosre-app:/var/www/discourse# wget
--2021-06-10 16:00:10--
Connecting to failed: Connection refused.

My question is, what can I do to make use of the host proxy inside the docker, especially in ./launcher rebuild app?

1 Like

Maybe see Replace with taobao mirror to resolve network error in China

There’s also a China template that you can include. You can see it in the templates folder. I’m not quite sure what it does.

(This isn’t a great answer, but it’s been two days and you don’t have any yet.)


Thanks Jay! The China template mirrors with, which is hosted by taobao/alibaba.

Inspired by that idea, I will try to mirror with a domestic one, hopefully hosted by alibaba too.