0

As I understand a docker-compose file, using the docker-compose up command, loads the images and starts the containers. Conversely using a Dockerfile file with the docker build command creates the image only. I think I am missing something here as things aren't working as I'd like.

Following the bitnami/wordpress instructions I got an install running fine using docker-compose up d. Can then access via localhost:81

version: '2'
services:
  mariadb:
    image: bitnami/mariadb:latest
    volumes:
      - /path/to/mariadb-persistence:/bitnami/mariadb
  wordpress:
    image: bitnami/wordpress:latest
    depends_on:
      - mariadb
    ports:
      - '81:80'
      - '443:443'
    volumes:
      - ./wordpress-persistence:/bitnami/wordpress
      - ./apache-persistence:/bitnami/apache
      - ./php-persistence:/bitnami/php

Because I want to be able to access this as domain.com.dev, I looked at implementing nginx-proxy. Following the instructions there, and with some inspiration from Docker nginx-proxy : proxy between containers, I came up with the following:

version: '2'
services:
  nginx-proxy:
    image: jwilder/nginx-proxy
    container_name: nginx-proxy
    restart: always
    ports:
      - "88:80"
    volumes:
      - "/var/run/docker.sock:/tmp/docker.sock:ro"

  mariadb:
    image: bitnami/mariadb:latest
    volumes:
      - //c/websites/domain_com/mariadb-persistence:/bitnami/mariadb
  domain.com.dev:
    image: bitnami/wordpress:latest
    depends_on:
      - mariadb
    ports:
      - '81:80'
    environment:
      - VIRTUAL_HOST=domain.com.dev
    volumes:
      - //c/websites/domain_com/wordpress-persistence:/bitnami/wordpress
      - //c/websites/domain_com/apache-persistence:/bitnami/apache
      - //c/websites/domain_com/php-persistence:/bitnami/php

Running docker-compose up -d with this appears to complete without error. However when I access domain.com.dev in a browser, I get a default Index of / page, which suggests I somehow got partway there but not all the way. Looking at the local folders, they get created but it seems like the wordpress-persistence does not get populated, which could explain the default view in the browser.

Any thoughts on why this isn't coming up as expected? Something obvious I missed?

1 Answer 1

0

1) For the first approach, you need "to finish" the configuration. If you don't have a running webserver (nginx, apache, etc.) (on port 80) - just change the port from 81 to 80:

ports:
      - '80:80'
      - '443:443'

and add the record "127.0.0.1 domain.com.dev" to your hosts file (/etc/hosts in linux).

P.S. you may change port from 88 to 80 at the second approach - it will work without changing hosts file

If you have a running wevserver on port 80 - then it is needed to you proxy directives at virtualhost config file. Here is an example:

server {
    listen 80 default_server;
    server_name _;

    include expires.conf;

    location / {
        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_set_header X-Forwarded-Proto $scheme;
        proxy_pass http://172.17.0.1:81;
        proxy_http_version 1.1;
    }
}

2) The second approach is usually used with dnsmasq configuration. Use this and this links to get more detailed information and examples of configuration.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.