0

Using the official redmine docker guide it is possible to start a redmine server connected to a postgresql database. I used the following commands:

docker run -d --name redmine_db -p 6543:5432 -e POSTGRES_PASSWORD=secret -e POSTGRES_USER=redmine postgres:9.5.1

docker run -d --name redmine_web -p 3001:3000 --link redmine_db:postgres redmine:3.2.3

But I have difficulties to run the same configuration with docker compose. Here is the first docker-compose.yml file I used:

version: '2'
services:
  webserver:
    image: redmine:3.2.3
    ports:
      - "3001:3000"
    links:
      - database:postgres

  database:
    image: postgres:9.5.1
    ports:
      - "6543:5432"
    environment:
      - POSTGRES_PASSWORD="secret"
      - POSTGRES_USER="redmine"

With docker compose the redmine server starts correctly but it ignores the postgres database container and uses the internal SQLite database instead.

I've also tried with the following environments in the webserver configuration:

environment:
  - POSTGRES_PORT_5432_TCP="5432"
  - POSTGRES_ENV_POSTGRES_USER="redmine"
  - POSTGRES_ENV_POSTGRES_PASSWORD="secret"

But without success. This time the redmine container does not start at all and displays the following error message:

 [!] There was an error parsing `Gemfile`: (<unknown>): did not find expected key while parsing a block mapping at line 2 column 3. Bundler cannot continue.

 #  from /usr/src/redmine/Gemfile:64
 #  -------------------------------------------
 #  if File.exist?(database_file)
 >    database_config = YAML::load(ERB.new(IO.read(database_file)).result)
 #    adapters = database_config.values.map {|c| c['adapter']}.compact.uniq
 #  -------------------------------------------
Sabbane
  • 2,938
  • 4
  • 21
  • 27
  • "difficulties"? What kind of difficulties? What error message do you have? – VonC Jul 15 '16 at 11:09
  • The first thing I'll check would be to make sure the container did start fully and it did not exit. `docker ps -a` is your container running? – Samuel Toh Jul 15 '16 at 11:10
  • Sorry, I've forgot to specify that the container starts correctly but ignores the database contaiener. I've just added it to the original post. – Sabbane Jul 15 '16 at 11:29
  • I have never use redmine before so it will be difficult for me to help u on the error. Since u have started the containers successfully before, firing it up again will be no difference to starting up through docker compose. I would recommend u to delete away all of the associated data volumes and try again. That is, `docker rm CONTAINER_ID -v` -v means remove volumes – Samuel Toh Jul 15 '16 at 13:20
  • Before running them again I always remove the old containers with docker rm -v CONTAINER. No data containers are used now, I'll configure them after a successful deployement. I thing the problem resides on how the docker compose daemon links the containers together. Somehow the redmine container can not access/recognize the database container. – Sabbane Jul 15 '16 at 13:31

1 Answers1

0

From docker-compose version 2 docs:

links with environment variables: As documented in the environment variables reference, environment variables created by links have been deprecated for some time. In the new Docker network system, they have been removed. You should either connect directly to the appropriate hostname or set the relevant environment variable yourself, using the link hostname:

web:
  links:
    - db
  environment:
    - DB_PORT=tcp://db:5432

In docker-compose v. 2 you should use networks instead. All services in docker-compose in one common network by default. In your config your webserver container can resolve database by database host without any links.

Cortwave
  • 4,747
  • 2
  • 25
  • 42