ノートより便利である:私はまだBukharov Sergey's answerで見ていないので、それはよりエレガントかもしれません。
これは私が思いついたものです。ネットワーク共有機能を実現するための2つの方法と、上記の方法を使用するときに現れるRedmine問題の1つのハックを発見しました。
方法1(優先それは非推奨だので、それは短いですが、そうでないかもしれないので?):
http {
server {
listen 80;
# Method 1: Access via alias from link
location /redmine/ {
proxy_pass http://redmine:3000/;
}
}
nginx.conf Container Linking
ドッキングウィンドウ-compose.yaml
version: '2'
services:
nginx:
image: nginx
ports:
- "80:80"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
# Method 1: Linking
links:
- redmine
redmine:
image: redmine
# Method 1: Exposing port to linked containers
expose:
- "3000"
方法2:Defining a Network
ドッキングウィンドウ-compose.yaml
http {
server {
listen 80;
# Method 2: Access via ip address in shared network
location /redmine_networked/ {
proxy_pass http://172.22.0.5:3000/;
}
}
}
Redmineのハックnginx.conf
version: '2'
services:
nginx:
image: nginx
ports:
- "80:80"
volumes:
- ./nginx/nginx.conf:/etc/nginx/nginx.conf
# Method 2
networks:
shared_net:
ipv4_address: 172.22.0.4
redmine:
image: redmine
# Method 2
networks:
shared_net:
ipv4_address: 172.22.0.5
# Method number 2: Via networks
networks:
shared_net:
driver: bridge
ipam:
config:
- subnet: 172.22.0.0/16
gateway: 172.22.0.1
:Accessing redmine via a suburl
上記の解決策は、Redmineののホーム・ページへのアクセスを可能とします。ただし、すべてのRedmine URLはルートを指します(例: '/ redmine'または '/ redmine_networked'の代わりに 'home'の場合は '/')。したがって、これらのリンクのどれも動作しません。 nginxがすべての '/' URLをRedmineにリダイレクトするように設定されていた場合、これは問題ではありません。次のハックはそうではないと仮定しています。
Redmineが設定されたURLを指すようにするには、config/environment.rbファイルを編集する必要があります。
ここにハックです:
> docker exec -it <redmine_container> bash
redmine> cd config
# We're going to install vim (this is a hack)
redmine> apt-get update
redmine> apt-get install vim
redmine> vim environment.rb
変更あなたのconfig/environment.rbに
Initialize the Rails application Rails.application.initialize!
の下部に次の行
RedmineApp::Application.routes.default_scope = "/redmine"
Initialize the Rails application Rails.application.initialize!
redmine> exit
> docker restart <redmine> (or just kill other docker process and run docker up again)
には、