Sunday, June 11, 2017

Dockerfile for phpmyadmin



FROM centos
#FROM httpd:latest
#RUN yum install -y update
RUN yum install -y httpd
#RUN systemctl start httpd
#RUN systemctl enable httpd
RUN yum install -y php
RUN yum install -y php-mysqlnd php-fpm php-dba
RUN yum install -y epel-release
Run yum install -y phpmyadmin
RUN mkdir -p /etc/phpMyAdmin
COPY ./config.inc.php /etc/phpMyAdmin/config.inc.php
COPY ./phpMyAdmin.conf /etc/httpd/conf.d/phpMyAdmin.conf
EXPOSE 80
ADD run-httpd.sh /run-httpd.sh
RUN chmod -v +x /run-httpd.sh
CMD ["/run-httpd.sh"]
#RUN service httpd start
#CMD  ["systemctl", "start", "httpd"]
#CMD [ "httpd" , "start" ]

#CMD [ "httpd" , "enable" ]

Changes in the hostmachine

Basic configuration for phpMyAdmin

vi /etc/httpd/conf.d/phpMyAdmin.conf

By default, the configuration for phpMyAdmin only allows access from the server on which it is installed. Find the following sections and change each IP address to the one you found in Step 3, or another IP address that will be connecting to phpMyAdmin remotely:

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

 <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
      Require ip 127.0.0.1
      Require ip ::1
    
Replace the above block ,with the below mentioned code

<Directory /usr/share/phpMyAdmin/>
   AddDefaultCharset UTF-8

 <IfModule mod_authz_core.c>
     # Apache 2.4
     <RequireAny>
   #    Require ip 127.0.0.1
   #    Require ip ::1
        Require all granted

Database configuration file

vi  /etc/phpMyadmin/config.inc.php

changes:
$cfg['Servers'][$i]['host']   : Mention the endpoint of database
$cfg['Servers'][$i][‘port’]    : Mention the port number
$cfg['Servers'][$i]['extension'] : ‘mysqli ‘;   // The php MYSQL extension to use

cat run-httpd.sh 
#!/bin/bash

# Make sure we're not confused by old, incompletely-shutdown httpd
# context after restarting the container.  httpd won't start correctly
# if it thinks it is already running.
rm -rf /run/httpd/* /tmp/httpd*

exec /usr/sbin/apachectl -DFOREGROUND

These all should be in one directory

Dockerfile
config.inc.php
phpMyAdmin.conf
run-httpd.sh

docker build -t phpmyadmin .
get docker image.
docker run -it --name admin -p 80:80 phpmyadmin
get docker container.

No comments:

Post a Comment