如何将两个容器合而为一

时间:2018-10-22 21:11:26

标签: php docker apache2

如果我去集装箱

sudo docker-compose exec web bash

我使用apache2在Linux docker中获得php7.2

如果我去集装箱

sudo docker-compose exec lets bash

我获得ssl证书:)) 但是我如何在一个环境中使用php7.2获得证书和apache2 这是我的代码,请看一看并给我答案非常感谢您的帮助

version: '2'

services:

 web:
   build: ./web
   environment:
      - APACHE_RUN_USER=#1000
   volumes:
      - ${APP_PATH_HOST}:${APP_PATH_CONTAINER}
   ports:
      - 8090:80
   working_dir: ${APP_PATH_CONTAINER}
   tty: true

 lets:
  build: ./lets
  hostname: www.some.domain.in.ua
  restart: always
  volumes_from:
    - letsencryptstore 
  ports:
    - "80:80"
    - "443:443"
  environment:
    LETS_ENCRYPT_EMAIL: "imediasun@gmail.com"
    LETS_ENCRYPT_DOMAINS: "some.domain.in.ua,www.some.domain.in.ua"
  labels:
    io.enonic.backup.data: "/etc/letsencrypt,/var/lib/letsencrypt"
 letsencryptstore:
  image: busybox
  volumes:
    - "/etc/letsencrypt"
    - "/var/lib/letsencrypt"  

 db:
  image: "mysql:5.7"
  volumes:
     - ./db:/var/lib/mysql
  environment:
     MYSQL_ROOT_PASSWORD: password
     MYSQL_DATABASE: database
     MYSQL_USER: user
     MYSQL_PASSWORD: password
  ports:
     - 3306:3306

 phpmyadmin:
          image: phpmyadmin/phpmyadmin:latest
          environment:
             - PMA_HOST=db
             - PMA_USER=user
             - PMA_PASSWORD=password
          volumes:
             - /sessions
          ports:
             - 8080:80  


 composer:
        image: composer:1.6
        volumes:
            - ${APP_PATH_HOST}:${APP_PATH_CONTAINER}
        working_dir: ${APP_PATH_CONTAINER}
        command: composer install

这是来自./lets目录的Dockerfile

FROM enoniccloud/apache2 as letsencrypt

MAINTAINER Erik Kaareng-Sunde <esu@enonic.com>

RUN rm /etc/apache2/sites-enabled/000-default.conf
RUN rm /etc/apache2/sites-enabled/default-ssl.conf

RUN apt-get update && apt-get -y install curl && apt-get clean
RUN curl -o /usr/local/bin/certbot-auto https://dl.eff.org/certbot-auto &&  \
  chmod +x /usr/local/bin/certbot-auto && \
  certbot-auto --os-packages-only -n


COPY index.html /var/www/html/index.html
COPY launcher.sh /usr/local/bin/launcher.sh
RUN chmod +x /usr/local/bin/launcher.sh

CMD /usr/local/bin/launcher.sh

这是来自./web目录的Dockerfile

FROM php:7.2-apache as phprepo

RUN docker-php-ext-install \
    pdo_mysql \
    && a2enmod \
    rewrite

    RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
    COPY utils/000-default.conf /etc/apache2/sites-available/000-default.conf
    EXPOSE 80
    RUN ["apt-get", "update"]
    RUN ["apt-get", "install", "-y", "vim"]
    RUN ["apt-get", "install", "-y", "nano"]
    RUN ["apt-get", "install", "-y", "sudo"]

我也看到端口冲突,我需要两个端口分别用于Web服务器80和443

0 个答案:

没有答案