access to a dockerized apache from local mochine

Get ubuntu

docker pull ubuntu:vivid

Start ubuntu container

docker run -ti ubuntu:vivid /bin/bash

Install apache

root@54a954be4ca3:/# apt-get install apache2

Type CTRL+P then CTRL+Q : this will exit the shell without killing the process
Now in the local machine, check out the container name

docker ps

Save the container with its apache installed (suppose your container name is happy_pasteur)

docker commit -a “witr ” -m “install apache2” happy_pasteur witr/myapache

Stop the container

docker stop happy_pasteur

Start apache in new container “myapache” and bind ports

docker run -d -p 9999:80 witr/myapache /usr/sbin/apache2ctl -D FOREGROUND

Finally browse http://localhost:9999