1

I have built an image using these steps:

download adminer package

wget https://www.adminer.org/static/download/4.2.4/adminer-4.2.4-en.php

mv adminer-4.2.4-en.php adminer.php

create docker file

vi dockerfile

FROM ubuntu
RUN apt-get -y install apache2 php5 php5-curl php5-cli php5-mysql php5-gd mysql-client mysql-server
RUN apt-get -y install postgresql postgresql-contrib
RUN apt-get -y install php5-pgsql
COPY adminer.php /var/www/html/
RUN chmod -R 777 /var/www/html/

build and run

docker build -t shantanuo/adminer1 .

docker run -i -t --rm -p 80:80 --name adminer1 shantanuo/adminer1


I need to run this command to start apache once I am inside the container.

sudo service apache2 start

How do I include this command in the dockerfile? (Build failed after adding CMD for this purpose.)

Is there any other (better) way of installing adminer.php package?

Is it possible to reduce the size of this image?

1
  • 1
    The trick is to run apache2 in non-daemon mode using something like CMD ["/usr/sbin/apache2 -D FOREGROUND"], or start with an Apache docker image such as hub.docker.com/_/httpd instead of ubuntu base image. Commented Feb 28, 2016 at 5:24

1 Answer 1

3

What you do is opening an interactive bash session and try to start a server.

It would be better if you started your same image in detached mode (-d) instead of -it, and let apache runs.
For that, as commented, you need to start FROM httpd:2.4 which:

Even better would be to use a PHP docker image:

FROM php:5.6-apache

That way, you don't even have to install apache or php. You just copy your php application.

Then, if you need to, you can still open a bash session with:

docker exec -it <yourContainer> bash
Sign up to request clarification or add additional context in comments.

6 Comments

I changed the base image. But now I am not able to include the required packages.
@shantanuo what error do you get? Don't forget with this new base image, you don't have to include the php package anymore.
Image got built correctly. But i get an error in the application : None of the supported PHP extensions (PgSQL, PDO_PgSQL) are available.
@shantanuo if you were on a machine where php is installed, what command would you type in order to install those extensions? Add those commands as RUN directives in your Dockerfile.
apt-get install php5-pgsql works for ubuntu base image but does not work with php:5.6-apache
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.