如何在原有的dockerfile上添加对应的镜像封装到docker
我是使用了开源的dockerdnmp
https://github.com/yeszao/dnmp
然后我参考了
https://github.com/klein0r/ph...
进行整合,代码如下
我把代码放入Dockerfile后的
RUN apt-get update
1 2 3 4 5 6 7 8 | # Install dependencies RUN apt-get update && apt-get upgrade -y --force-yes && apt-get install -y --force-yes --no-install-recommends apt-utils RUN apt-get -y --force-yes install git vim RUN mkdir -p /opt/analytics-mqtt && git clone https://github.com/klein0r/php-analytics-mqtt.git /opt/analytics-mqtt RUN cd /opt/analytics-mqtt && php composer.phar install WORKDIR /opt/analytics-mqtt |
// 请把代码文本粘贴到下方(请勿用图片代替代码)
这是我docker-compose.yml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 | version: "3" services: nginx: image: nginx:alpine ports: - "80:80" - "443:443" volumes: - ./www/:/var/www/html/:rw - ./conf/conf.d:/etc/nginx/conf.d/:ro - ./conf/nginx.conf:/etc/nginx/nginx.conf:ro - ./log/:/var/log/dnmp/:rw restart: always networks: - net-php72 - net-php56 - net-php54 php72: build: context: . args: PHP_VERSION: 7.2 SOURCE_LIST: stretch XDEBUG_VERSION: 2.6.1 SWOOLE_VERSION: 4.2.1 SUPPORT_MCRYPT: "false" BUILT_IN_OPCACHE: "true" expose: - "9000" volumes: - ./www/:/var/www/html/:rw - ./conf/php.ini:/usr/local/etc/php/php.ini:ro - ./conf/php-fpm.conf:/usr/local/etc/php-fpm.d/www.conf:rw - ./log/:/var/log/dnmp/:rw restart: always cap_add: - SYS_PTRACE networks: - net-php72 - net-mysql - net-redis php56: build: context: . args: PHP_VERSION: 5.6 SOURCE_LIST: jessie XDEBUG_VERSION: 2.5.5 SWOOLE_VERSION: 2.0.11 SUPPORT_MCRYPT: "true" BUILT_IN_OPCACHE: "true" expose: - "9000" volumes: - ./www/:/var/www/html/:rw - ./conf/php.ini:/usr/local/etc/php/php.ini:ro - ./conf/php-fpm.conf:/usr/local/etc/php-fpm.d/www.conf:rw - ./log/:/var/log/dnmp/:rw restart: always cap_add: - SYS_PTRACE networks: - net-php56 - net-mysql - net-redis php54: build: context: . args: PHP_VERSION: 5.4 SOURCE_LIST: jessie XDEBUG_VERSION: 2.4.1 SWOOLE_VERSION: "false" SUPPORT_MCRYPT: "true" BUILT_IN_OPCACHE: "false" expose: - "9000" volumes: - ./www/:/var/www/html/:rw - ./conf/php.ini:/usr/local/etc/php/php.ini:ro - ./conf/php-fpm.conf:/usr/local/etc/php-fpm.d/www.conf:rw - ./log/:/var/log/dnmp/:rw restart: always cap_add: - SYS_PTRACE networks: - net-php54 - net-mysql - net-redis mysql: image: mysql:8.0 ports: - "3307:3306" volumes: - ./conf/mysql.cnf:/etc/mysql/conf.d/mysql.cnf:ro - ./mysql/:/var/lib/mysql/:rw restart: always networks: - net-mysql environment: MYSQL_ROOT_PASSWORD: "123456" redis: image: redis:4.0 restart: always networks: - net-redis ports: - "6380:6379" phpmyadmin: image: phpmyadmin/phpmyadmin:latest ports: - "8080:80" networks: - net-mysql environment: - PMA_HOST=mysql - PMA_PORT=3306 phpredisadmin: image: erikdubbelboer/phpredisadmin:latest ports: - "8081:80" networks: - net-redis environment: - REDIS_1_HOST=redis - REDIS_1_PORT=6379 networks: net-php72: net-php56: net-php54: net-mysql: net-redis: |
这是我的Dockerfile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | ARG PHP_VERSION FROM php:${PHP_VERSION}-fpm ARG SOURCE_LIST ARG XDEBUG_VERSION ARG SWOOLE_VERSION ARG REDIS_VERSION=4.1.1 ARG SUPPORT_MCRYPT ARG BUILT_IN_OPCACHE COPY ./sources.list/$SOURCE_LIST /etc/apt/sources.list RUN apt-get update # Composer RUN php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" \ && php composer-setup.php \ && php -r "unlink('composer-setup.php');" \ && mv composer.phar /bin/composer \ && composer config -g repo.packagist composer https://packagist.phpcomposer.com # Install extensions from source COPY ./extensions /tmp/extensions RUN chmod +x /tmp/extensions/install.sh \ && /tmp/extensions/install.sh \ && rm -rf /tmp/extensions # More extensions # 1. soap requires libxml2-dev. # 2. xml, xmlrpc, wddx require libxml2-dev and libxslt-dev. # 3. Line `&& :\` do nothing just for better reading. RUN apt-get install -y libfreetype6-dev libjpeg62-turbo-dev libpng-dev \ && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \ && docker-php-ext-install gd \ && :\ && apt-get install -y libicu-dev \ && docker-php-ext-install intl \ && :\ && apt-get install -y libxml2-dev \ && apt-get install -y libxslt-dev \ && docker-php-ext-install soap \ && docker-php-ext-install xsl \ && docker-php-ext-install xmlrpc \ && docker-php-ext-install wddx \ && :\ && apt-get install -y libbz2-dev \ && docker-php-ext-install bz2 \ && :\ && docker-php-ext-install zip \ && docker-php-ext-install pcntl \ && docker-php-ext-install pdo_mysql \ && docker-php-ext-install mysqli \ && docker-php-ext-install mbstring \ && docker-php-ext-install exif \ && docker-php-ext-install bcmath \ && docker-php-ext-install calendar \ && docker-php-ext-install sockets \ && docker-php-ext-install gettext \ && docker-php-ext-install shmop \ && docker-php-ext-install sysvmsg \ && docker-php-ext-install sysvsem \ && docker-php-ext-install sysvshm \ && docker-php-ext-install mysql \ #&& docker-php-ext-install ZendGuardLoader \ #&& docker-php-ext-install opcache \ #&& docker-php-ext-install pdo_firebird \ #&& docker-php-ext-install pdo_dblib \ #&& docker-php-ext-install pdo_oci \ #&& docker-php-ext-install pdo_odbc \ #&& docker-php-ext-install pdo_pgsql \ #&& docker-php-ext-install pgsql \ #&& docker-php-ext-install oci8 \ #&& docker-php-ext-install odbc \ #&& docker-php-ext-install dba \ #&& docker-php-ext-install interbase \ #&& :\ #&& apt-get install -y curl \ #&& apt-get install -y libcurl3 \ #&& apt-get install -y libcurl4-openssl-dev \ #&& docker-php-ext-install curl \ #&& :\ #&& apt-get install -y libreadline-dev \ #&& docker-php-ext-install readline \ #&& :\ #&& apt-get install -y libsnmp-dev \ #&& apt-get install -y snmp \ #&& docker-php-ext-install snmp \ #&& :\ #&& apt-get install -y libpspell-dev \ #&& apt-get install -y aspell-en \ #&& docker-php-ext-install pspell \ #&& :\ #&& apt-get install -y librecode0 \ #&& apt-get install -y librecode-dev \ #&& docker-php-ext-install recode \ #&& :\ #&& apt-get install -y libtidy-dev \ #&& docker-php-ext-install tidy \ #&& :\ #&& apt-get install -y libgmp-dev \ #&& ln -s /usr/include/x86_64-linux-gnu/gmp.h /usr/include/gmp.h \ #&& docker-php-ext-install gmp \ #&& :\ #&& apt-get install -y postgresql-client \ #&& apt-get install -y mysql-client \ #&& :\ #&& apt-get install -y libc-client-dev \ #&& docker-php-ext-configure imap --with-kerberos --with-imap-ssl \ #&& docker-php-ext-install imap \ #&& :\ #&& apt-get install -y libldb-dev \ #&& apt-get install -y libldap2-dev \ #&& docker-php-ext-configure ldap --with-libdir=lib/x86_64-linux-gnu \ #&& docker-php-ext-install ldap \ #&& :\ #&& apt-get install -y libmagickwand-dev \ #&& pecl install imagick-3.4.3 \ #&& docker-php-ext-enable imagick \ && :\ && apt-get install -y libmemcached-dev zlib1g-dev \ && pecl install memcached-2.2.0 \ && pecl install Mosquitto-alpha \ && docker-php-ext-enable memcached |
希望能兼容封装进去,但是我尝试了修修改改,报错依然很多