designetwork(EN)

IT technical memo of networking

Proxy setting for installing Gem with Docker Redmine

f:id:daichi703n:20180421011243p:plain

When adding a plugin to Docker Redmine, if you need to install the Gem package, set the Proxy environment variable in docker-compose.yml.

The problems that occurred, the contents of the investigation, and how to respond are shown.

Environment

Redmine Docker Image: sameersbn/docker-redmine

github.com

Each parameter is set with this docker-compose.yml.

docker-redmine/docker-compose.yml at master · sameersbn/docker-redmine · GitHub

Proxy setting with environment variable

The environment variable setting for the container is defined by docker-compose.yml. I do not want to include proxy information including authentication information in the docker-compose.yml file, so I take over the environment variables of the host OS.

version: '2'

services:
  redmine:
    image: sameersbn/redmine:3.4.4-2
    container_name: redmine
    depends_on:
    - postgresql
    restart: always
    environment:
    - TZ=Asia/Tokyo
    - HTTP_PROXY=${HTTP_PROXY}
    - http_proxy=${HTTP_PROXY}
    - HTTPS_PROXY=${HTTPS_PROXY}
    - https_proxy=${HTTPS_PROXY}
    - NO_PROXY=${NO_PROXY}
    - no_proxy=${NO_PROXY}
    <snip>

Problem behavior

As you can see in this log, installation on Gem has failed. It is caused by not communicating with Proxy from the log of UnknownHostError. Also from tcpdump on the host OS, rubygems.org name resolution (DNS) request was generated. (Originally Proxy communication without DNS)

$docker-compose up
Starting postgres-redmine ... 
Starting postgres-redmine ... doneRecreating redmine        ... 
Recreating redmine        ... doneAttaching to postgres-redmine, redmine
postgres-redmine | Initializing datadir...
redmine       | Initializing logdir...
redmine       | Initializing datadir...
redmine       | Symlinking dotfiles...
redmine       | Installing configuration templates...
redmine       | Configuring redmine...
postgres-redmine | Initializing certdir...
postgres-redmine | Initializing logdir...
postgres-redmine | Initializing rundir...
postgres-redmine | Setting resolv.conf ACLs...
postgres-redmine | Creating database user: redmine
postgres-redmine | Creating database: redmine_production...
postgres-redmine | ? Granting access to redmine user...
postgres-redmine | Starting PostgreSQL 9.6...
postgres-redmine | LOG:  database system was shut down at 2018-04-19 12:22:57 UTC
postgres-redmine | LOG:  MultiXact member wraparound protections are now enabled
postgres-redmine | LOG:  database system is ready to accept connections
postgres-redmine | LOG:  autovacuum launcher started
redmine       | Configuring redmine::database...
redmine       | Configuring redmine::unicorn...
redmine       | Configuring redmine::secret_token...
redmine       | Generating a session token...
redmine       | Note:
redmine       |   All old sessions will become invalid.
redmine       |   Please specify the REDMINE_SECRET_TOKEN parameter for persistence.
redmine       |   **SHOULD** be defined if you have a load-balancing Redmine cluster.
redmine       | Configuring redmine::max_concurrent_ajax_uploads...
redmine       | Configuring redmine::sudo_mode...
redmine       | Configuring redmine::autologin_cookie...
redmine       | Configuring redmine::email_delivery...
redmine       | Configuring redmine::backups...
redmine       | Configuring redmine::backups::schedule...
redmine       | Configuring nginx...
redmine       | Configuring nginx::redmine...
redmine       | Installing plugins...
redmine       | Installing gems required by plugins...
redmine       | Gem::RemoteFetcher::UnknownHostError: no such name
redmine       | (https://rubygems.org/gems/rubyzip-1.2.1.gem)
redmine       | An error occurred while installing rubyzip (1.2.1), and Bundler cannot continue.
redmine       | Make sure that `gem install rubyzip -v '1.2.1'` succeeds before bundling.
redmine       | 
redmine       | In Gemfile:
redmine       |   write_xlsx was resolved to 0.85.3, which depends on
redmine       |     zip-zip was resolved to 0.3, which depends on
redmine       |       rubyzip
redmine exited with code 5

Basically, gem should have no problems if you set http_proxy,https_proxy as an environment variable, but in my environment it did not work as expected.

Since the package information can be obtained from the above (and tcpdump separation), it is possible to specify that the Bundler is satisfactory and that it is not the expected proxy action at the time of Gem install.

The setting of no_proxy was incorrect

Cause as summarized here, no_proxy setting error.

http://en-designetwork.hatenablog.com/entry/2018/04/28/gem-install-failure-proxyen-designetwork.hatenablog.com

(NG) no_proxy=,localhost,127.0.0.1
(OK) no_proxy=localhost,127.0.0.1

Resolving the problem

By modifying no_proxy above Proxy communication can be successfully done even in installing the Gem package required for the plugin.

Conclusion - Proxy setting for installing Gem with Docker Redmine

If you set no_proxy in the Proxy environment, Gem package download fails if the description is incorrect .

By properly setting no_proxy , it is now possible to download from the Rubygems via the Proxy even the Gem package that is required additionally by the Redmine plugin.


This Blog is English Version of my JP's.

Sorry if my English sentences are incorrect.

designetwork