Skip to content
This repository has been archived by the owner on Nov 20, 2020. It is now read-only.

Decompose the Compose files #69

Open
allamand opened this issue Nov 18, 2016 · 14 comments
Open

Decompose the Compose files #69

allamand opened this issue Nov 18, 2016 · 14 comments

Comments

@allamand
Copy link

Hello,

Is it possible for compose-ui instead of reading docker-compose.yml file, to read docker-compose*.yml files ?

I used to specify several docker-compose-files with -f when using docker-compose, that allow me to simplify big docker-compose file maintenability ex :

  -rw-r--r-- 1 cloud docker 3211 Jul 11 09:13 docker-compose-base.yml
  -rw-r--r-- 1 cloud docker  684 Jul  5 10:22 docker-compose-logs.yml
  -rw-r--r-- 1 cloud docker  629 Aug 10 08:44 docker-compose-networks.yml
  -rw-r--r-- 1 cloud docker  771 Jul 11 09:12 docker-compose-traefik.yml
  -rw-r--r-- 1 cloud docker  377 Jul 11 09:18 docker-compose-volumes.yml
@francescou
Copy link
Owner

Hi, only docker-compose.yml projects are supported, at the moment.

I will investigate about the technical feasibility of this

@mmacai
Copy link

mmacai commented Mar 23, 2017

@allamand If you want to use something like docker-compose -f docker-compose.yml -f docker-compose.a.yml up you can create .env file in directory with those files and put there:
COMPOSE_FILE=docker-compose.yml:docker-compose.a.yml. You should be able to use multiple compose files, but one should be named docker-compose.yml.

@edyan
Copy link

edyan commented Aug 20, 2017

+1 I have created a tool that "recompose" the docker command line via a config file (https://github.com/edyan/stakkr : it reads a list of services to start and get the right yml files). That's completely dynamic and I can't use your UI (unfortunately!).

My config files are there : https://github.com/edyan/stakkr/tree/master/stakkr/static/services + I use a lot of env variables ...

As docker compose has no api and it's a pure cli tool, maybe it's impossible to "guess" what has been loaded ?

Thanks !

Edit : I found a way to write the full config dumped from docker-compose config and to mount it in a directory that I set as the working dir ... but that does not work ... i have a GUI with no containers. My config is the following (am I missing something?):

networks:
  stakkr:
    driver: bridge
    ipam:
      config:
      - subnet: 192.168.102.0/24
services:
  apache:
    container_name: mydev_apache
    environment:
      APACHE_GID: '1000'
      APACHE_UID: '1000'
    hostname: mydev_apache
    image: edyan/apache:2.2
    links:
    - php
    mem_limit: 512M
    networks:
      stakkr: null
    volumes:
    - /projects/mydev/home/www-data:/home/www-data:rw
    - /projects/mydev/logs/apache:/var/log/apache2:rw
    - /projects/mydev/www:/var/www:rw
  compose-ui:
    container_name: mydev_ui
    hostname: mydev_ui
    image: francescou/docker-compose-ui
    networks:
      stakkr: null
    volumes:
    - /tmp/stakkr/mydev:/compose-files/stakkr:rw
    - /var/run/docker.sock:/var/run/docker.sock:rw
    working_dir: /compose-files
  elasticsearch:
    container_name: mydev_elasticsearch
    hostname: mydev_elasticsearch
    image: elasticsearch:1.6
    mem_limit: 512M
    networks:
      stakkr: null
    volumes:
    - /projects/mydev/data/elasticsearch:/usr/share/elasticsearch/data:rw
  maildev:
    container_name: mydev_maildev
    hostname: mydev_maildev
    image: djfarrelly/maildev
    networks:
      stakkr: null
  mysql:
    container_name: mydev_mysql
    environment:
      MYSQL_ROOT_PASSWORD: changeme
    hostname: mydev_mysql
    image: mysql:5.5
    mem_limit: 1024M
    networks:
      stakkr: null
    volumes:
    - /projects/mydev/conf/mysql-override:/etc/mysql/conf.d:rw
    - /projects/mydev/data/mysql:/var/lib/mysql:rw
  php:
    cap_add:
    - NET_ADMIN
    - NET_RAW
    container_name: mydev_php
    environment:
      ENVIRONMENT: dev
      FPM_GID: '1000'
      FPM_UID: '1000'
    hostname: mydev_php
    image: edyan/php:5.6-git
    mem_limit: 512M
    networks:
      stakkr: null
    volumes:
    - /projects/mydev/conf/php-fpm-override:/etc/php/7.0/fpm/user-conf.d:rw
    - /projects/mydev/conf/php-fpm-override:/etc/php/7.1/fpm/user-conf.d:rw
    - /projects/mydev/conf/php-fpm-override:/etc/php/7.2/fpm/user-conf.d:rw
    - /projects/mydev/conf/php-fpm-override:/etc/php5/fpm/user-conf.d:rw
    - /projects/mydev/home/www-data:/home/www-data:rw
    - /projects/mydev/logs/php:/var/log/php:rw
    - /projects/mydev/www:/var/www:rw
  phpmyadmin:
    container_name: mydev_phpmyadmin
    environment:
      PHP_UPLOAD_MAX_FILESIZE: 128M
      PMA_HOSTS: mysql
      PMA_PASSWORD: changeme
      PMA_USER: root
    hostname: mydev_phpmyadmin
    image: phpmyadmin/phpmyadmin
    networks:
      stakkr: null
version: '2.2'

@francescou
Copy link
Owner

Hello @edyan
could you please tell me the steps to reproduce the issue?

I see you mount a volume /tmp/stakkr/mydev:/compose-files/stakkr:rw inside the docker-compose-ui container, I guess this folder contains the output of doker-compose config?

@edyan
Copy link

edyan commented Aug 21, 2017

Hi @francescou, yes that's the output ... to reproduce actually you'll have to install my tool (http://stakkr.readthedocs.io/en/latest/pages/installation.html#installation-under-linux) then dump the config (stakkr-compose config) somewhere like I did, then mount it with your image and see if you get a list. Of course that takes time so if I can help ... let me know !

@francescou
Copy link
Owner

do you save the output of stakkr-compose config to a file named docker-compose.yml ?

@edyan
Copy link

edyan commented Aug 21, 2017

yes I put it into /tmp/stakkr/mydev and I mount that that I set as a workdir.

From your app I see the conf I have pasted above so it's taken into account

@francescou
Copy link
Owner

ok so you can see your docker-compose project in the docker-compose-ui "Projects" left column, right?

@edyan
Copy link

edyan commented Aug 21, 2017

Absolutely but I have no container to start / stop, etc ...

@francescou
Copy link
Owner

at the very beginning you don't have any service running, so you will not see any service until you click on "up" (docker-compose up).

@edyan
Copy link

edyan commented Aug 21, 2017

Ok ! So you read events from docker but don't read the initial state, right ? (as I set docker-compose-ui in my docker-compose.yml, it starts at the same time than other containers).

@francescou
Copy link
Owner

Yes, it's correct: you can see the services only after the docker composition has been created.

since you are running docker-compose-ui using that docker-compose.yml file you should be able to see all the services as long the docker compose project name is equal to the name of the folder containing the docker-compose.yml file.

For example, if you start a composition /tmp/stakkr/mydev/my-stakkr/docker-compose.yml you will see a project named "my-stakkr" on the left column of docker-compose-ui that should be active (a green "on" label should be displayed).
Otherwise, check is the output of docker inspect docker_compose_ui | jq '.[0].Config.Labels["com.docker.compose.project"]' -r is equal to "my-stakkr"

@edyan
Copy link

edyan commented Aug 22, 2017

Hi @francescou

My feedback :

  • I believe there is 3 mistakes in the doc :
    1/ Typo : "Then open your browser to http://localhost:8080" when the port is 5000
    2/ Typo : "to use use your own docker-compose"
    3/ When mounting the current directory where the compose file is, we get as a project a simple dot (".") and no container when we click the dot, as nothing goes to the url. But when we mount the parent directory (in my case /tmp/stakk:/compose-files:rw and not /tmp/stakkr/mydev:/compose-files/stakkr:rw, that works well, I see my project and I can start / stop my container. And .... I can do an up from outside, reload the page and see a change in the status (so it's dynamic, and it's great).

Conclusion:

  • It looks like there is a small issue in the doc :), replace $(pwd) by $(dirname $(pwd)) and I think that'll work !

Thanks for your support

EDIT : for people who use multiple yml file, do a docker-compose config, dump your config in a directory, mount the parent directory of that directory and you'll be able to use docker-compose-ui !

@francescou
Copy link
Owner

@edyan you're right.
Thank you very much, I've fixed the documentation.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants