如何在单个容器中 运行 两个 Docker 图像?
How can I run TWO Docker images in a SINGLE Container?
我想用 PHP Image & Apache Image 创建一个单一的 Docker 容器,这里是我的 docker 文件。
Docker 文件名:单-container.dockerfile
# PHP image from docker hub
FROM php:7.2-cli
# Apache image from docker hub
FROM httpd:2.4
# public-html is path for my local codebase
COPY ./public-html/ /usr/local/apache2/htdocs/
在 docker CLI 中,当我 运行 这个命令时:docker build -f single-container.dockerfile . -t mysinglecontainer:latest
I'm getting below error.
请指教,有哪些改动需要修改?
把.
移到最后
docker build -f httpd.Dockerfile -t mysinglecontainer:latest .
请务必在您的命令中使用正确的 Dockerfile
名称,名称是 single-container.dockerfile
所以命令是:
docker build -f single-container.dockerfile -t mysinglecontainer:latest .
找到解决方案
Here is my Github URL: https://github.com/yogig/dockercron/
FROM php:7.2-fpm-alpine
LABEL maintainer="xxx@xxx.de" \
muz.customer="xxx" \
muz.product="xxx" \
container.mode="development"
#https://pkgs.alpinelinux.org/packages
RUN apk add --no-cache --virtual .deps autoconf tzdata build-base libzip-dev mysql-dev gmp-dev \
libxml2-dev libpng-dev zlib-dev freetype-dev jpeg-dev icu-dev openldap-dev libxslt-dev &&\
docker-php-ext-install zip xml mbstring json intl gd pdo pdo_mysql iconv soap \
dom gmp fileinfo sockets bcmath mysqli ldap xsl &&\
echo 'date.timezone="Europe/Berlin"' >> "${PHP_INI_DIR}"/php.ini &&\
cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime &&\
echo 'Europe/Berlin' > /etc/timezone &&\
curl -s https://www.phing.info/get/phing-latest.phar > /bin/phing &&\
chmod a+x /bin/phing &&\
ln -s /bin/phing /usr/local/bin/phing &&\
ln -s /bin/phing /usr/local/phing &&\
ln -s /bin/phing /usr/bin/phing &&\
apk del .deps &&\
apk add --no-cache libzip mysql libxml2 libpng zlib freetype jpeg icu gmp git subversion libxslt openldap \
apache2 apache2-ldap apache2-proxy libreoffice openjdk11-jre ghostscript msttcorefonts-installer \
terminus-font ghostscript-fonts &&\
ln -s /usr/lib/apache2 /usr/lib/apache2/modules &&\
ln -s /usr/sbin/httpd /etc/init.d/httpd &&\
update-ms-fonts
# copy crontabs for root user
COPY crontab.txt /etc/crontabs/root
#https://github.com/docker-library/httpd/blob/3ebff8dadf1e38dbe694ea0b8f379f6b8bcd993e/2.4/alpine/httpd-foreground
#https://github.com/docker-library/php/blob/master/7.2/alpine3.10/fpm/Dockerfile
CMD ["/bin/sh", "-c", "rm -f /usr/local/apache2/logs/httpd.pid && httpd -DBACKGROUND && php-fpm"]
will install PHP Alpine image
(1) FROM php:7.2-fpm-alpine
Configuration for Apache
(2) apk add --no-cache libzip mysql libxml2 libpng zlib freetype jpeg icu gmp git subversion libxslt openldap \
apache2 apache2-ldap apache2-proxy libreoffice openjdk11-jre ghostscript msttcorefonts-installer \
terminus-font ghostscript-fonts
Last:在 Docker CLI 中,我 运行 命令 docker-compose up
现在在我的单一容器中,两者都 PHP & Apache 运行ning 成功。
Note: To see content of docker-compose.yaml file, visit
https://github.com/yogig/dockercron
我想用 PHP Image & Apache Image 创建一个单一的 Docker 容器,这里是我的 docker 文件。
Docker 文件名:单-container.dockerfile
# PHP image from docker hub
FROM php:7.2-cli
# Apache image from docker hub
FROM httpd:2.4
# public-html is path for my local codebase
COPY ./public-html/ /usr/local/apache2/htdocs/
在 docker CLI 中,当我 运行 这个命令时:docker build -f single-container.dockerfile . -t mysinglecontainer:latest
I'm getting below error.
请指教,有哪些改动需要修改?
把.
移到最后
docker build -f httpd.Dockerfile -t mysinglecontainer:latest .
请务必在您的命令中使用正确的 Dockerfile
名称,名称是 single-container.dockerfile
所以命令是:
docker build -f single-container.dockerfile -t mysinglecontainer:latest .
找到解决方案
Here is my Github URL: https://github.com/yogig/dockercron/
FROM php:7.2-fpm-alpine
LABEL maintainer="xxx@xxx.de" \
muz.customer="xxx" \
muz.product="xxx" \
container.mode="development"
#https://pkgs.alpinelinux.org/packages
RUN apk add --no-cache --virtual .deps autoconf tzdata build-base libzip-dev mysql-dev gmp-dev \
libxml2-dev libpng-dev zlib-dev freetype-dev jpeg-dev icu-dev openldap-dev libxslt-dev &&\
docker-php-ext-install zip xml mbstring json intl gd pdo pdo_mysql iconv soap \
dom gmp fileinfo sockets bcmath mysqli ldap xsl &&\
echo 'date.timezone="Europe/Berlin"' >> "${PHP_INI_DIR}"/php.ini &&\
cp /usr/share/zoneinfo/Europe/Berlin /etc/localtime &&\
echo 'Europe/Berlin' > /etc/timezone &&\
curl -s https://www.phing.info/get/phing-latest.phar > /bin/phing &&\
chmod a+x /bin/phing &&\
ln -s /bin/phing /usr/local/bin/phing &&\
ln -s /bin/phing /usr/local/phing &&\
ln -s /bin/phing /usr/bin/phing &&\
apk del .deps &&\
apk add --no-cache libzip mysql libxml2 libpng zlib freetype jpeg icu gmp git subversion libxslt openldap \
apache2 apache2-ldap apache2-proxy libreoffice openjdk11-jre ghostscript msttcorefonts-installer \
terminus-font ghostscript-fonts &&\
ln -s /usr/lib/apache2 /usr/lib/apache2/modules &&\
ln -s /usr/sbin/httpd /etc/init.d/httpd &&\
update-ms-fonts
# copy crontabs for root user
COPY crontab.txt /etc/crontabs/root
#https://github.com/docker-library/httpd/blob/3ebff8dadf1e38dbe694ea0b8f379f6b8bcd993e/2.4/alpine/httpd-foreground
#https://github.com/docker-library/php/blob/master/7.2/alpine3.10/fpm/Dockerfile
CMD ["/bin/sh", "-c", "rm -f /usr/local/apache2/logs/httpd.pid && httpd -DBACKGROUND && php-fpm"]
will install PHP Alpine image
(1) FROM php:7.2-fpm-alpine
Configuration for Apache
(2) apk add --no-cache libzip mysql libxml2 libpng zlib freetype jpeg icu gmp git subversion libxslt openldap \
apache2 apache2-ldap apache2-proxy libreoffice openjdk11-jre ghostscript msttcorefonts-installer \
terminus-font ghostscript-fonts
Last:在 Docker CLI 中,我 运行 命令 docker-compose up
现在在我的单一容器中,两者都 PHP & Apache 运行ning 成功。
Note: To see content of docker-compose.yaml file, visit https://github.com/yogig/dockercron