FROM ubuntu:latest Run <<EOF apt update apt install -y apache2 mysql-server php libapache2-mod-php php-mysql php-curl php-json php-cgi php-cli php-zip php-xml php-mbstring apt install wget EOF ENV WP_DB_NAME="Btsample" ENV WP_DB_USER="Bt" ENV WP_DB_PASS="**********" CMD service mysql start && apachectl -D FOREGROUND RUN mysql <<EOF CREATE DATABASE $WP_DB_NAME; CREATE USER '$WP_DB_USER'@'localhost' IDENTIFIED BY '$WP_DB_PASS'; GRANT ALL PRIVILEGES ON $WP_DB_NAME.* TO '$WP_DB_USER'@'localhost'; FLUSH PRIVILEGES; EXIT; EOF RUN wget https://wordpress.org/latest.tar.gz RUN tar -xvzf latest.tar.gz RUN cp -R wordpress/* /var/www/html/ RUN tee /etc/apache2/sites-available/wordpress.conf > /dev/null <<EOF <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/html ServerName wordpress.com ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost> EOF RUN rm var/www/html/index.html EXPOSE 80 CMD ["apachectl", "-D", "FOREGROUND"] - Are you asking about the "mysql" client? or the "mysqld" server? Apache should be background. To have two things in the "foreground", launch them in separate "terminals".Rick James– Rick James2024-11-21 00:04:39 +00:00Commented Nov 21, 2024 at 0:04
- rick , thanks for replying , actually I am trying to build a docker file for wordpress , where I also need mysql and apache and php for it but the problem here is to run both mysql and apache in foreground , i am able to run apache in foreground by CMD [apachectl -D foreground] but not in the case of mysql which is required to create database and user ,means mysql should be running to create databases and users , so what should I do to keep mysql runningBharat Thakur– Bharat Thakur2024-11-21 07:32:13 +00:00Commented Nov 21, 2024 at 7:32
- I don't see the need for either apache or mysql being in the "foreground". Do you have some reference that recommends that?Rick James– Rick James2024-11-21 21:36:39 +00:00Commented Nov 21, 2024 at 21:36
- actually , I have a task and the task to build an image of wordpress in docker in 1 go, the rule is i don't have to open that container of that image for starting my apache and mysql ,and keeping them both alive while building the image , and it is giving me hard time ,Bharat Thakur– Bharat Thakur2024-11-22 04:49:07 +00:00Commented Nov 22, 2024 at 4:49
- anyone, ???????Bharat Thakur– Bharat Thakur2025-01-01 06:39:17 +00:00Commented Jan 1 at 6:39
Add a comment |