Multiple dependent ? Dockerfiles building a LAMP container

Stephane

I'm trying to build a LAMP container and I have already built several containers: httpd 2.4.23, redis 3.0.7, mysql 5.6.30 by compiling them myself from source code downloaded archives. I have based all of these above on the debian container.

Now that I'm doing the php 5.6.20 container it complains that it does not know about apache and mysql.

Here is the Dockerfile for the php container:

FROM debian

RUN apt-get update
RUN apt-get install -y build-essential;
RUN apt-get install -y cmake;
RUN apt-get install -y libfreetype6-dev libjpeg-dev libpng12-dev libcurl4-openssl-dev libbz2-dev libxml2-dev libxslt-dev libgd2-xpm-dev php5-imap libz-dev

WORKDIR /usr/bin/
COPY php-5.6.20.tar.gz /usr/bin/
RUN gzip -d php-5.6.20.tar.gz
RUN tar -xvf php-5.6.20.tar
RUN ln -s php-5.6.20 php

WORKDIR /usr/bin/php/
RUN ./configure \
  --prefix=/usr/bin/ \
  --with-apxs2=/usr/bin/apache/bin/apxs \
  --with-config-file-path=/usr/bin/php-5.6.20/ \
  --enable-libgcc \
  --with-mysqli=/usr/bin/mysql/mysql_config \
  --with-zlib-dir=/usr \
  --with-jpeg-dir=/usr \
  --with-png-dir=/usr \
  --with-gd \
  --enable-gd-native-ttf \
  --with-freetype-dir=/usr \
  --enable-ftp \
  --enable-xml \
  --enable-zip \
  --with-bz2 \
  --enable-wddx \
  --without-pear \
  --enable-mbstring \
  --with-curl

RUN make

RUN make install

I wonder if I should base it instead on: FROM httpd:2.4.23. But then I would need to base httpd on the mysql one, and / or on the redis one... I don't really like that setup.

I have also installed Docker Compose but I wonder if it could be helpful in my situation.

UPDATE: Here is the fully working Dockerfile

FROM debian

RUN apt-get update
RUN apt-get install -y build-essential;
RUN apt-get install -y cmake;
RUN apt-get install -y openssl libssl-dev;
RUN apt-get install -y libpcre3 libpcre3-dev

WORKDIR /usr/bin/
COPY httpd-2.4.23.tar.gz /usr/bin/
RUN gzip -d httpd-2.4.23.tar.gz
RUN tar -xvf httpd-2.4.23.tar
RUN ln -s httpd-2.4.23 httpd
COPY apr-1.5.2.tar.gz /usr/bin/httpd/srclib/
COPY apr-util-1.5.4.tar.gz /usr/bin/httpd/srclib/
WORKDIR /usr/bin/httpd/srclib/
RUN gzip -d apr-1.5.2.tar.gz
RUN gzip -d apr-util-1.5.4.tar.gz
RUN tar -xvf apr-1.5.2.tar
RUN tar -xvf apr-util-1.5.4.tar
RUN ln -s apr-1.5.2 apr;
RUN ln -s apr-util-1.5.4 apr-util

WORKDIR /usr/bin/httpd/
RUN ./configure \
  --prefix=/usr/bin/apache \
  --enable-rewrite \
  --enable-deflate \
  --enable-ssl

RUN make

RUN make install

RUN apt-get update
RUN apt-get install -y libncurses-dev

COPY mysql-5.6.30.tar.gz /usr/bin/
WORKDIR /usr/bin/
RUN gzip -d mysql-5.6.30.tar.gz
RUN tar -xvf mysql-5.6.30.tar
RUN ln -s mysql-5.6.30 mysql

WORKDIR /usr/bin/mysql/
RUN mkdir install; mkdir install/data; mkdir install/var; mkdir install/etc; mkdir install/tmp

RUN cd /usr/bin/mysql/; cmake \
  -DCMAKE_INSTALL_PREFIX=/usr/bin/mysql/install \
  -DWITH_INNOBASE_STORAGE_ENGINE=1 \
  -DMYSQL_DATADIR=/usr/bin/mysql/install/data \
  -DDOWNLOAD_BOOST=1 \
  -DWITH_BOOST=/usr/bin/mysql/install/boost \
  -DMYSQL_UNIX_ADDR=/usr/bin/mysql/install/tmp/mysql.sock

RUN make

RUN make install

RUN apt-get update
RUN apt-get install -y libfreetype6-dev libjpeg-dev libpng12-dev libcurl4-openssl-dev libbz2-dev libxml2-dev libxslt-dev libgd2-xpm-dev php5-imap libz-dev

WORKDIR /usr/bin/
COPY php-5.6.20.tar.gz /usr/bin/
RUN gzip -d php-5.6.20.tar.gz
RUN tar -xvf php-5.6.20.tar
RUN ln -s php-5.6.20 php

WORKDIR /usr/bin/php/
RUN ./configure \
  --prefix=/usr/bin/php \
  --with-apxs2=/usr/bin/apache/bin/apxs \
  --with-config-file-path=/usr/bin/php-5.6.20/ \
  --enable-libgcc \
  --with-mysqli=/usr/bin/mysql/install/bin/mysql_config \
  --with-zlib-dir=/usr \
  --with-jpeg-dir=/usr \
  --with-png-dir=/usr \
  --with-gd \
  --enable-gd-native-ttf \
  --with-freetype-dir=/usr \
  --enable-ftp \
  --enable-xml \
  --enable-zip \
  --with-bz2 \
  --enable-wddx \
  --without-pear \
  --enable-mbstring \
  --with-openssl
  --with-curl

RUN make

RUN make install

ENTRYPOINT ["/usr/bin/apache/bin/apachectl", "start", "-D FOREGROUND"]

EXPOSE 80

# Build the container: docker build -t stephaneeybert/httpd:2.4.23 .
# Run the container: docker run -d -p 127.0.0.1:80:80 --name httpd stephaneeybert/httpd:2.4.23
# Check that the port is open: nmap -p 8081 localhost
Haoming Zhang

If you need apache running in your container, you can install apache in your image with above Dockerfile, just as the same as you install the build-essential stuffs. Which means:

RUN apt-get install -y apache2

or similar command. If you also need the configure for this apache application, you can use ADD or COPY command to add your configure file from outside to inside of your container. More details can be found here.

If you need apache as an independent container, you can use docker-compse to achieve it. Start apache in another container, then use depends_on to config the dependency between your containers. You may use ports to change the port number of each container, so they can communicate between each other.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

Docker: Multiple Dockerfiles in project

From Dev

angular: Validate multiple dependent fields

From Dev

Building ios corePlot with Xcode 5.0 using a Dependent project scenario

From Dev

PHPExcel Multiple Dropdown list that dependent

From Dev

How to build dependent project when building a module in maven

From Dev

building RPM package: force to install in path of a dependent relocated package

From Dev

Matching multiple independent (or dependent) paths

From Dev

Building Multiple Indexes at Once

From Dev

Building docker images from a source directory using different dockerfiles

From Dev

docker-compose: using multiple Dockerfiles for multiple services

From Dev

Building programs on multiple platforms?

From Dev

Deploy multiple LAMP instances on Google Compute Engine

From Dev

Multiple dockerfiles in one docker or multiple images from one dockerfile

From Dev

Dependent Validation on Multiple Objects Rails

From Dev

What is the easiest way to run bash dependent dockerfiles on windows?

From Dev

Is there any way to using hadolint for multiple dockerfiles?

From Dev

Need multiple styles dependent on Listboxitem

From Dev

How to make container dependent control?

From Dev

Linker errors when building DLL dependent on static lib Crypto++

From Dev

Building programs on multiple platforms?

From Dev

Building dChart based on Container in Vaadin

From Dev

Backup and restore LXC container with LAMP stack - MySQL cannot start in container

From Dev

Working with multiple dependent PhpStorm projects

From Dev

How to call multiple dependent functions?

From Dev

AWS beanstalk not building docker container

From Dev

container not building with mentioned dockerfile - multiple containers

From Dev

Multiple dependent selects in Knockout JS

From Dev

Multiple php-fpm versions on LAMP Server

From Dev

Multiple NSURLSession dependent download tasks

Related Related

  1. 1

    Docker: Multiple Dockerfiles in project

  2. 2

    angular: Validate multiple dependent fields

  3. 3

    Building ios corePlot with Xcode 5.0 using a Dependent project scenario

  4. 4

    PHPExcel Multiple Dropdown list that dependent

  5. 5

    How to build dependent project when building a module in maven

  6. 6

    building RPM package: force to install in path of a dependent relocated package

  7. 7

    Matching multiple independent (or dependent) paths

  8. 8

    Building Multiple Indexes at Once

  9. 9

    Building docker images from a source directory using different dockerfiles

  10. 10

    docker-compose: using multiple Dockerfiles for multiple services

  11. 11

    Building programs on multiple platforms?

  12. 12

    Deploy multiple LAMP instances on Google Compute Engine

  13. 13

    Multiple dockerfiles in one docker or multiple images from one dockerfile

  14. 14

    Dependent Validation on Multiple Objects Rails

  15. 15

    What is the easiest way to run bash dependent dockerfiles on windows?

  16. 16

    Is there any way to using hadolint for multiple dockerfiles?

  17. 17

    Need multiple styles dependent on Listboxitem

  18. 18

    How to make container dependent control?

  19. 19

    Linker errors when building DLL dependent on static lib Crypto++

  20. 20

    Building programs on multiple platforms?

  21. 21

    Building dChart based on Container in Vaadin

  22. 22

    Backup and restore LXC container with LAMP stack - MySQL cannot start in container

  23. 23

    Working with multiple dependent PhpStorm projects

  24. 24

    How to call multiple dependent functions?

  25. 25

    AWS beanstalk not building docker container

  26. 26

    container not building with mentioned dockerfile - multiple containers

  27. 27

    Multiple dependent selects in Knockout JS

  28. 28

    Multiple php-fpm versions on LAMP Server

  29. 29

    Multiple NSURLSession dependent download tasks

HotTag

Archive