Docker Community Forums

Share and learn in the Docker community.

Webserver and browser in one image


(Hardbegin) #1

I am an absolute beginner in Docker and I would like to create an image/container with webserver (apache2) and firefox to show the contains of webserver.
I tried to find the solution, but I have not found. In Dockerfile you will be able to find my attempts to detect it (the comments - showed by big letters).

My files:

Dockerfile
FROM ubuntu:14.04
RUN apt-get -y update && apt-get -y install apache2 firefox supervisor curl openssh-server
RUN mkdir -p /var/lock/apache2 /var/run/apache2 /var/run/sshd /var/log/supervisor
ENV APACHE_RUN_USER www-data
ENV APACHE_RUN_GROUP www-data
ENV APACHE_LOG_DIR /var/log/apache2
ENV APACHE_LOCK_DIR /var/lock/apache2
ENV APACHE_PID_FILE /var/run/apache2.pid
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
EXPOSE 80
ADD apache-config.conf_old /etc/apache2/sites-enabled/000-default.conf
#CMD service apache2 start
#CMD ifconfig -a
#CMD /usr/sbin/apache2ctl status
RUN export uid=1000 gid=1000 &&
mkdir -p /home/developer &&
echo “developer:x:${uid}:${gid}:developer,:/home/developer:/bin/bash” >> /etc/passwd &&
echo “developer:x:${uid}:” >> /etc/group &&
echo “developer ALL=(ALL) NOPASSWD: ALL” > /etc/sudoers.d/developer &&
chmod 0440 /etc/sudoers.d/developer &&
chown ${uid}:${gid} -R /home/developer

USER developer
ENV HOME /home/developer
CMD ["/usr/bin/supervisord"]
#CMD service apache2 status
#CMD cat /etc/apache2/sites-enabled/000-default.conf
#CMD curl localhost
CMD firefox localhost

supervisord.conf
[supervisord]
nodaemon=true
[program:apache2]
command=/usr/sbin/apache2ctl -D “FOREGROUND” -k start
redirect_stderr=true
[program:sshd]
command=/usr/sbin/sshd -D

apache-config.conf_old
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request’s Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
#ServerName www.example.com

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html

# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf

Error messages:
prompt:~/myDockerbuild01$ docker run -t --rm -p 80:80 -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix first-image
docker: Error response from daemon: driver failed programming external connectivity on endpoint big_engelbart (734fa58a3432407c909e61c14303200767a168aaebd4774faf22b577923fc0d9): Error starting userland proxy: listen tcp 0.0.0.0:80: bind: address already in use.
And nothing to show, no browser.

prompt:~/myDockerbuild01$ docker run -t --rm -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix first-image
Gtk-Message: Failed to load module “canberra-gtk-module”

(firefox:6): GLib-GObject-CRITICAL **: g_object_ref: assertion ‘object->ref_count > 0’ failed

(firefox:6): GLib-GObject-CRITICAL **: g_object_unref: assertion ‘object->ref_count > 0’ failed

(firefox:6): GLib-GObject-CRITICAL **: g_object_ref: assertion ‘object->ref_count > 0’ failed

(firefox:6): GLib-GObject-CRITICAL **: g_object_unref: assertion ‘object->ref_count > 0’ failed
Gtk-Message: Failed to load module “canberra-gtk-module”

(/usr/lib/firefox/plugin-container:83): GLib-GObject-CRITICAL **: g_object_ref: assertion ‘object->ref_count > 0’ failed

(/usr/lib/firefox/plugin-container:83): GLib-GObject-CRITICAL **: g_object_unref: assertion ‘object->ref_count > 0’ failed

(/usr/lib/firefox/plugin-container:83): GLib-GObject-CRITICAL **: g_object_ref: assertion ‘object->ref_count > 0’ failed

(/usr/lib/firefox/plugin-container:83): GLib-GObject-CRITICAL **: g_object_unref: assertion ‘object->ref_count > 0’ failed
And after these error messages from GUI the firefox started with message “Unable to connect”

What is the problem? How can I solve it? Many thanks in advance.