Docker compõe dados do volume do host não na pasta do contêiner

0

Estou tentando adicionar o gitlab à minha próxima vps de nuvem. Como sempre, tenho problemas com os certificados ssl. A pasta contêiner está vazia, enquanto a pasta do host não está. O conteúdo do host não é adicionado ao volume do contêiner. A pasta do contêiner está vazia ( /etc/gitlab/ssl ).

version: '2'
services:
  proxy:
    image: jwilder/nginx-proxy
    container_name: proxy
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./proxy/conf.d:/etc/nginx/conf.d
      - ./proxy/vhost.d:/etc/nginx/vhost.d
      - ./proxy/html:/usr/share/nginx/html
      - ./proxy/certs:/etc/nginx/certs:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
    networks:
      - proxy-tier
    restart: always

  letsencrypt-companion:
    image: alastaircoote/docker-letsencrypt-nginx-proxy-companion
    container_name: letsencrypt-companion
    volumes_from:
      - proxy
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./proxy/certs:/etc/nginx/certs:rw
    restart: always

  web:
    image: nginx
    container_name: nextcloud_webserver
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
    links:
      - app
      - collabora
    volumes_from:
      - app
    environment:
      - VIRTUAL_HOST=${DOMAIN}
      - VIRTUAL_NETWORK=nginx-proxy
      - VIRTUAL_PORT=80
      - LETSENCRYPT_HOST=${DOMAIN}
      - LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
networks:
      - proxy-tier
    restart: always

  app:
    image: nextcloud:fpm
    container_name: nextcloud_fpm
    links:
      - db
    volumes:
      - ./nextcloud/apps:/var/www/html/apps
      - ./nextcloud/config:/var/www/html/config
      - ./nextcloud/data:/var/www/html/data
    networks:
      - proxy-tier
    restart: always

  db:
    image: mariadb
    container_name: db
    volumes:
      - ./nextcloud/db:/var/lib/mysql
    environment:
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
    networks:
      - proxy-tier
    restart: always

  redis:
    image: redis
    container_name: redis
    networks:
      - proxy-tier
    restart: always

  collabora:
    image: collabora/code
    container_name: collabora
    cap_add:
      - MKNOD
    environment:
      - domain=${DOMAIN}
    networks:
      - proxy-tier
    restart: always

  gitlab:
    image: gitlab/gitlab-ce:latest
    container_name: gitlab
    restart: always
    hostname: ${GITDOMAIN}
    environment:
      VIRTUAL_HOST: ${GITDOMAIN}
      VIRTUAL_NETWORK: nginx-proxy
      VIRTUAL_PORT: 80
      LETSENCRYPT_HOST: ${GITDOMAIN}
      LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
      GITLAB_OMNIBUS_CONFIG: |
          external_url "https://${GITDOMAIN}"
          nginx['ssl_certificate'] = "/etc/gitlab/ssl/fullchain.pem"
          nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/key.pem"
          # Add any other gitlab.rb configuration here, each on its own line
    volumes:
      - ./gitlab/config:/etc/gitlab
      - ./gitlab/logs:/var/log/gitlab
      - ./gitlab/data:/var/opt/gitlab
      - /opt/nextcloud-docker/.examples/proxy/certs/${GITDOMAIN}:/etc/gitlab/ssl:rw
    networks:
      - proxy-tier

networks:
  proxy-tier:
    external:
      name: nginx-proxy

2017/08/19 09:26:17 [emerg] 6465#0: BIO_new_file("/etc/gitlab/ssl/fullchain.pem") failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/etc/gitlab/ssl/fullchain.pem','r') error:2006D080:BIO routines:BIO_new_file:no such file)

docker inspect gitlab

{
                "Type": "bind",
                "Source": "/opt/nextcloud-docker/.examples/proxy/certs/domain",
                "Destination": "/etc/gitlab/ssl",
                "Mode": "rw",
                "RW": true,
                "Propagation": "rprivate"
            }

"Volumes": {
                "/etc/gitlab": {},
                "/etc/gitlab/ssl": {},
                "/var/log/gitlab": {},
                "/var/opt/gitlab": {}
            },

Talvez esse /etc/gitlab masque o /etc/gitlab/ssl . Eu li sobre recipientes mascarando arquivos host, isso é muito confuso e novo para mim. Como faço para depurar este problema?

    
por metanerd 19.08.2017 / 13:16

1 resposta

0

Acontece que o gitlab apenas exibe nginx error.log sempre ao iniciar. Então o certificado ssl já estava lá e funcionando. Eu ainda tive problemas para configurar a porta para trabalhar com jwilder nginx-proxy. Então é assim que minha última configuração se parece e funciona:

crie um link simbólico para o .env com gitlab-docker$ln -s ../.env .env

docker-compose.yml oficial do nextcloud: ./docker-compose.yml

version: '2'
services:
  proxy:
    image: jwilder/nginx-proxy
    container_name: proxy
    ports:
      - 80:80
      - 443:443
    volumes:
      - ./proxy/conf.d:/etc/nginx/conf.d
      - ./proxy/vhost.d:/etc/nginx/vhost.d
      - ./proxy/html:/usr/share/nginx/html
      - ./proxy/certs:/etc/nginx/certs:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
    networks:
      - proxy-tier
    restart: always

  letsencrypt-companion:
    image: alastaircoote/docker-letsencrypt-nginx-proxy-companion
    container_name: letsencrypt-companion
    volumes_from:
      - proxy
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ./proxy/certs:/etc/nginx/certs:rw
    restart: always

  web:
    image: nginx
    container_name: nextcloud_webserver
    volumes:
      - ./nginx.conf:/etc/nginx/nginx.conf:ro
    links:
      - app
      - collabora
    volumes_from:
      - app
    environment:
      - VIRTUAL_HOST=${DOMAIN}
      - VIRTUAL_NETWORK=nginx-proxy
      - VIRTUAL_PORT=80
      - LETSENCRYPT_HOST=${DOMAIN}
      - LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
    networks:
      - proxy-tier
    restart: always

  app:
    image: nextcloud:fpm
    container_name: nextcloud_fpm
    links:
      - db
    volumes:
      - ./nextcloud/apps:/var/www/html/apps
      - ./nextcloud/config:/var/www/html/config
      - ./nextcloud/data:/var/www/html/data
    networks:
      - proxy-tier
    restart: always

  db:
    image: mariadb
    container_name: db
    volumes:
      - ./nextcloud/db:/var/lib/mysql
    environment:
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=${MYSQL_PASSWORD}
    networks:
      - proxy-tier
    restart: always

  redis:
    image: redis
    container_name: redis
    networks:
      - proxy-tier
    restart: always

  collabora:
    image: collabora/code
    container_name: collabora
    cap_add:
      - MKNOD
    environment:
      - domain=${DOMAIN}
    networks:
      - proxy-tier
    restart: always

networks:
  proxy-tier:
    external:
      name: nginx-proxy

./gitlab-docker/docker-compose.yml

version: '2'

services:
  gitlab:
    image: gitlab/gitlab-ce:latest
    container_name: gitlab
    restart: always
    hostname: ${GITDOMAIN}
    environment:
      VIRTUAL_HOST: ${GITDOMAIN}
      VIRTUAL_NETWORK: nginx-proxy
      VIRTUAL_PORT: 80
      LETSENCRYPT_HOST: ${GITDOMAIN}
      LETSENCRYPT_EMAIL: ${LETSENCRYPT_EMAIL}
      GITLAB_OMNIBUS_CONFIG: |
        external_url 'https://${GITDOMAIN}'
        nginx['ssl_certificate'] = "/etc/gitlab/ssl/fullchain.pem"
        nginx['ssl_certificate_key'] = "/etc/gitlab/ssl/key.pem"
        nginx['listen_port'] = 80
        nginx['listen_https'] = false
        nginx['proxy_set_headers'] = {  "X-Forwarded-Proto" => "https", "X-Forwarded-Ssl" => "on" }
        # Add any other gitlab.rb configuration here, each on its own line
    ports:
      - '3022:22'
    volumes:
      - gitcerts:/etc/gitlab/ssl:ro
      - ../gitlab/config:/etc/gitlab
      - ../gitlab/logs:/var/log/gitlab
      - ../gitlab/data:/var/opt/gitlab
    networks:
      - proxy-tier

networks:
  proxy-tier:
    external:
      name: nginx-proxy

volumes:
  gitcerts:
    driver_opts:
      type: none
      device: /opt/nextcloud-docker/.examples/proxy/certs/${GITDOMAIN}
      o: bind
  • Observe o volume nomeado para acessar os certificados do gitlab ( docker volume ls para listar volumes e docker volume inspect $name para exibir o volume ponto de montagem, que no meu caso é /var/lib/docker/volumes/gitlabdocker_gitcerts/_data ).
  • Observe também as diretivas de escuta específicas para o gitlab, créditos para aqueles abaixo.

Créditos:

  • link
  • link (para explicar como o jwilder / nginx-proxy funciona)
por 20.08.2017 / 11:22