5 Jan 2014

Ubuntu 13.10/Tomcat7 stephens/tomcat7-mysql Docker Image

Here are some quick notes on using my Ubuntu 13.10 docker image with the following installed: ssh, supervisor, tomcat7, apache2, mysql 5.5, phpmyadmin.

Download The Image

I've posted the stephens/tomcat7-mysql image to the docker site and  you can pull it with the command:

docker pull stephens/tomcat7-mysql

The root password is password.

Start The Image

Start the image with the command:

sudo docker run -d -privileged -p 22 -p 80 -p 8080 stephens/sshd

The image specifies an ENTRYPOINT that runs supervisord which runs sshd and then /root/start.sh. The -privileged option is not required but it avoids an apache2 error described here.

You can execute the docker ps command to see which port to whcih sshd has been mapped.

There's documentation on using supervisord with Docker here.

Specify Port Mapping

Here's an example of specifying the ports you want to use for mapping of sshd, apache2 and tomcat:

sudo docker run -d -p 9122:22 -p 9180:80 -p 9181:8080 stephens/tomcat7-mysql

Change The Password

You should change the passwords for the root user, tomcat7 and mysql and then commit a copy of the running container to save the new password to the image.

ssh root@localhost -p 9122

Change the tomcat password in the /etc/tomcat7/tomcat-users.xml file.

mysql -u root -p
mysql> UPDATE mysql.user SET Password=PASSWORD('password') WHERE User='root';
mysql> exit;

While the container is still running, execute the docker ps command to get its container id and then execute the commit command to save the image with the same entrypoint and port specifications:

docker commit -run='{"Cmd": ["/usr/bin/supervisord","-n"], "PortSpecs": ["22","80","8080"]}' c3c75a870311 stephens/myimage