Today we'll be creating a new Joomla container for kghp's 3x website.

Get to the Docker04 server

Once you're ssh'd in, start by taking a look at the /root/site-joomla-template. Copy that directory recursively to create a new site folder.

cd /root/  
cp -r site-joomla-template/ joomla-kghp  

Now we need to make some modifications specific to this new site.

/root/joomla-kghp/docker-compose.yml

joomla:  
  image: psd/joomla:latest
  ports:
    - "5516:80"
  container_name: tmp3x
  volumes:
    - ./vhosts:/var/www/vhosts/:rw
    - ./sites:/etc/nginx/sites-available:rw
  command: setup-joomla
  environment:
    - SERVER_NAME=tmp3x.psd401.net
  external_links:
    - mailrelay

You'll need to replace everything that contains tmp to kghp (Insert site name here).

In vim this regex command works wonderfully: :%s/tmp/kghp/g
Or you can use sed:
sed -i 's/tmp/kghp/g' joomla-summerschool/docker-compose.yml

You'll also need to change the port so it doesn't conflict with any other container:
sed -i 's/5516/55xx/g' joomla-summerschool/docker-compose.yml
Because we are lazy Efficient

Now you should now have a docker-compose file like the following

joomla:  
  image: psd/joomla:latest
  ports:
    - "5518:80"
  container_name: kghp3x
  volumes:
    - ./vhosts:/var/www/vhosts/:rw
    - ./sites:/etc/nginx/sites-available:rw
  command: setup-joomla
  environment:
    - SERVER_NAME=kghp3x.psd401.net
  external_links:
    - mailrelay

Find the docker image here
Repeat this for the nginx site config as well:

rename 's/tmp/kghp/g' joomla-kghp/sites/tmp.psd401.net  
sed -i 's/tmp/kghp/g' joomla-kghp/sites/kghp.psd401.net  

You should now see the following:

/root/joomla-kghp/sites/kghp3x.psd401.net

# handle non-ssl https from the nginx load balancer
# (we are not ssl'd on the internal network but we need https sent to fastcgi)                 
map $http_x_forwarded_proto $fastcgi_https {  
    default on;
    https on;
}

server {  
  listen     80;
  server_name localhost;
  #server_name kghp3x.psd401.net;
  ### The public root folder of the site
  root   /var/www/vhosts/kghp3x.psd401.net/httpdocs;

  ### The default index file is the joomla index.php
  index index.php;

  ### Where to write the site access log
  access_log  /var/www/vhosts/kghp3x.psd401.net/logs/access.log;
  error_log   /var/www/vhosts/kghp3x.psd401.net/logs/error.log;

  ### include the default joomla config that is generic for all vhosts
  include /etc/nginx/conf/joomla.conf;

  # Pass all .php files onto a php-fpm/php-fcgi server.
  # see https://nealpoole.com/blog/2011/04/setting-up-php-fastcgi-and-nginx-dont-trust-the-tutorials-check-your-configuration/
  # see http://cnedelcu.blogspot.com/2010/05/nginx-php-via-fastcgi-important.html
  location ~ \.php$ {
     # Zero-day exploit defense.
     # http://forum.nginx.org/read.php?2,88845,page=3
     # Won't work properly (404 error) if the file is not stored on this server, which is entirely possible with php-fpm/php-fcgi.
     # Comment the 'try_files' line out if you set up php-fpm/php-fcgi on another machine.  And then cross your fingers that you won't get hacked.
     try_files $uri =404;

     #fastcgi_split_path_info ^(.+\.php)(/.+)$;
     include fastcgi_params;
     fastcgi_index index.php;
     fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
     fastcgi_intercept_errors on;
     fastcgi_param HTTPS $fastcgi_https;
     fastcgi_pass unix:/var/run/kghp3x.psd401.net-fpm.sock;
  }
}

Alright, now for the moment of truth. Run docker-compose from your new site folder:

cd joomla-kghp  
docker-compose up -d  

You shouldn't have run into any issues, it may take a few seconds.

docker ps

CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS              PORTS                                        NAMES  
54d52c6e3e3d        psd/joomla:latest         "/tmp/setup.sh setup-"   3 seconds ago       Up 2 seconds        22/tcp, 0.0.0.0:5518->80/tcp                 kghp3x  
b10f01d827a7        psd/joomla:latest         "/tmp/setup.sh setup-"   44 minutes ago      Up 44 minutes       22/tcp, 0.0.0.0:5517->80/tcp                 summerschool3x  
efa1f7e8ea3d        psd/joomla:latest         "/tmp/setup.sh setup-"   56 minutes ago      Up 56 minutes       22/tcp, 0.0.0.0:5516->80/tcp                 facilities3x  
a948879580b1        psd/joomla:latest         "/tmp/setup.sh setup-"   23 hours ago        Up 23 hours         22/tcp, 0.0.0.0:5502->80/tcp                 vge3x  
5eae56b8c9b7        psd/joomla:latest         "/tmp/setup.sh setup-"   23 hours ago        Up 23 hours         22/tcp, 0.0.0.0:5511->80/tcp                 phs3x  
a0ed5c6e3d22        psd/joomla:latest         "/tmp/setup.sh setup-"   23 hours ago        Up 23 hours         22/tcp, 0.0.0.0:5507->80/tcp                 pes3x  
daa9a7f3569f        psd/joomla:latest         "/tmp/setup.sh setup-"   23 hours ago        Up 23 hours         22/tcp, 0.0.0.0:5515->80/tcp                 mes3x  
0fb2298d40bf        psd/joomla:latest         "/tmp/setup.sh setup-"   23 hours ago        Up 23 hours         22/tcp, 0.0.0.0:5510->80/tcp                 kpm3x  
405026b6c513        psd/joomla:latest         "/tmp/setup.sh setup-"   23 hours ago        Up 23 hours         22/tcp, 0.0.0.0:5514->80/tcp                 kms3x  
30d48f40ee47        psd/joomla:latest         "/tmp/setup.sh setup-"   23 hours ago        Up 23 hours         22/tcp, 0.0.0.0:5509->80/tcp                 hrm3x  
581bbfbc9810        psd/joomla:latest         "/tmp/setup.sh setup-"   23 hours ago        Up 23 hours         22/tcp, 0.0.0.0:5504->80/tcp                 hhe3x  
789c8e28513e        psd/joomla:latest         "/tmp/setup.sh setup-"   23 hours ago        Up 23 hours         22/tcp, 0.0.0.0:5513->80/tcp                 hbh3x  
c9f522adb7d0        psd/joomla:latest         "/tmp/setup.sh setup-"   23 hours ago        Up 23 hours         22/tcp, 0.0.0.0:5508->80/tcp                 gms3x  
4cb9d55e7905        psd/joomla:latest         "/tmp/setup.sh setup-"   23 hours ago        Up 23 hours         22/tcp, 0.0.0.0:5512->80/tcp                 ghh3x  
dbdae5b7da98        psd/joomla:latest         "/tmp/setup.sh setup-"   23 hours ago        Up 23 hours         22/tcp, 0.0.0.0:5503->80/tcp                 ees3x  
11372919dd15        psd/joomla:latest         "/tmp/setup.sh setup-"   23 hours ago        Up 23 hours         22/tcp, 0.0.0.0:5506->80/tcp                 des3x  
2268f3a94b48        psd/joomla:latest         "/tmp/setup.sh setup-"   23 hours ago        Up 23 hours         22/tcp, 0.0.0.0:5505->80/tcp                 aes3x  
f7c9d8261b47        psd/joomla:latest         "/tmp/setup.sh setup-"   24 hours ago        Up 24 hours         22/tcp, 0.0.0.0:5501->80/tcp                 ves3x-test  
bff223915c6c        psd/samba                 "samba.sh -u www-data"   2 weeks ago         Up 2 weeks          0.0.0.0:139->139/tcp, 0.0.0.0:445->445/tcp   samba  
bbcc573a0479        dockermailrelay_postfix   "/root/run.sh"           3 months ago        Up 4 weeks          0.0.0.0:25->25/tcp                           mailrelay  

Notice the new kghp container on the top! You can also curl localhost:5518 to see the response, if you get 502 or 404 you've done something wrong. You should see the Joomla setup html.

Setup Load Balancer

You'll now need a way to get to this Joomla instance.
Connect to the load balancer and grab the template

/etc/nginx/sites-available/tmp3x.psd401.net

server {  
  listen 80;
  server_name tmp3x.psd401.net;
  rewrite ^/(.*) https://tmp3x.psd401.net/$1 permanent;
}


server {  
  listen 443 ssl;
  server_name tmp3x.psd401.net;

  location / {
    add_header 'Access-Control-Allow-Origin' '*';
    add_header 'Access-Control-Allow-Credentials' 'true';
    add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE';
    add_header 'Access-Control-Allow-Headers' 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
    proxy_set_header X-Forwarded-Host $host;
    #proxy_set_header X-Forwarded-Server $host;
    #proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host tmp3x.psd401.net;
    #proxy_redirect http://tmp3x.apps1.psd401.net/ https://tmp3x.psd401.net/;
    dav_methods PUT DELETE;
    proxy_pass http://vmnocwsdocker04.peninsula.wednet.edu:5516;
    fastcgi_read_timeout 60000;
    fastcgi_send_timeout 60000;
    send_timeout 60000;
    proxy_read_timeout 60000;
    proxy_send_timeout 60000;
  }
}

Create a new conf based on the template, and replace the tmp/port with your new site name/port.

cp /etc/nginx/sites-available/tmp3x.psd401.net /etc/nginx/sites-available/kghp3x.psd401.net  
sed -i 's/tmp/kghp/g' /etc/nginx/sites-available/kghp3x.psd401.net  
sed -i 's/5516/5518/g' /etc/nginx/sites-available/kghp3x.psd401.net  

Then make a link to this available site to the enabled sites and reload nginx to make the changes live.

ln -s /etc/nginx/sites-available/kghp3x.psd401.net /etc/nginx/sites-enabled/kghp3x.psd401.net  
service nginx reload  

DNS

Now the final step to make the site active, entering it in DNS.

  • On Windows DNS Manager select the psd401.net zone.
  • Create a new CNAME
  • Alais name field: kghp3x
  • Fully qualified domain name field: vmnocwsldblnc01.psd401.net.

Now visit the URL and continue to setup Joomla!

Joomla! setup

Granted you've made it this far, this should be a no brainer for you. Here's screenshots and instruction anyway...

For the admin password, use the server password for now. The webmaster will likely change it.

Press Next, setup the proper database connections. You'll likely need to go into the mysql server and setup a database. Let's not get into that here.

After you've configured the database and gone through the setup, you're ready to hand this off to the webmaster.

Preparing for production

One thing to take note is changing the site's DNS address will require not only changes to the nginx config on the load balancer, but also the nginx config on the joomla-site/sites/tmp3x.psd401.net. Second line from the bottom of the config where the fastcgi_param HTTP_HOST needs to match the public DNS name.

Setup for SAMBA

If needed setup this server's files for access through the Samba container.

/root/samba-docker/docker-compose.yml

samba:  
  image: psd/samba
  ports:
    - "139:139"
    - "445:445"
  container_name: samba
  volumes:
    - /root/joomla-aes3x/vhosts/aes3x.psd401.net/:/var/www/vhosts/aes:rw
    - /root/joomla-ees3x/vhosts/ees3x.psd401.net/:/var/www/vhosts/ees:rw
    - /root/joomla-vge3x/vhosts/vge3x.psd401.net/:/var/www/vhosts/vge:rw
    - /root/joomla-ves3x-test/vhosts/ves3x.psd401.net/:/var/www/vhosts/ves:rw
    - /root/joomla-hhe3x/vhosts/hhe3x.psd401.net/:/var/www/vhosts/hhe:rw
    - /root/joomla-pes3x/vhosts/pes3x.psd401.net/:/var/www/vhosts/pes:rw
    - /root/joomla-gms3x/vhosts/gms3x.psd401.net/:/var/www/vhosts/gms:rw
    - /root/joomla-hrm3x/vhosts/hrm3x.psd401.net/:/var/www/vhosts/hrm:rw
    - /root/joomla-kpm3x/vhosts/kpm3x.psd401.net/:/var/www/vhosts/kpm:rw
    - /root/joomla-phs3x/vhosts/phs3x.psd401.net/:/var/www/vhosts/phs:rw
    - /root/joomla-ghh3x/vhosts/ghh3x.psd401.net/:/var/www/vhosts/ghh:rw
    - /root/joomla-hbh3x/vhosts/hbh3x.psd401.net/:/var/www/vhosts/hbh:rw
    - /root/joomla-mes3x/vhosts/mes3x.psd401.net/:/var/www/vhosts/mes:rw
    - /root/joomla-kms3x/vhosts/kms3x.psd401.net/:/var/www/vhosts/kms:rw
    - /root/joomla-des3x/vhosts/des3x.psd401.net/:/var/www/vhosts/des:rw
    - /root/joomla-facilities/vhosts/facilities3x.psd401.net/:/var/www/vhosts/facilities:rw
    - /root/joomla-kghp/vhosts/kghp3x.psd401.net/:/var/www/vhosts/kghp:rw
    - /root/joomla-staff/vhosts/staff3x.psd401.net/:/var/www/vhosts/staff:rw
    - /root/joomla-summerschool/vhosts/summerschool3x.psd401.net/:/var/www/vhosts/summerschool:rw
    - /root/joomla-pools/vhosts/pools3x.psd401.net/:/var/www/vhosts/pools:rw
    - /root/joomla-knowledgebase/vhosts/knowledgebase3x.psd401.net/:/var/www/vhosts/knowledgebase:rw
  command: -u "username;supersecretpassword" -s "PSD Noc Joomla;/var/www/vhosts;yes;no;no;www-data"

Following the scheme, add the site to the volumes list. This allows the webmaster to connect to this server and access the site's hosted directories.

Automatic container startup

By default Docker does not automatically start containers, hence an upstart script is used to ensure all startup correctly.

/etc/init.d/start-containers.conf

description "Docker Containers"  
author "Brandon Martin"  
start on filesystem and started docker  
stop on runlevel [!2345]  
respawn  
script  
  /usr/bin/docker start samba
  /usr/bin/docker start mailrelay
  /usr/bin/docker start aes3x
  /usr/bin/docker start des3x
  /usr/bin/docker start ees3x
  /usr/bin/docker start gms3x
  /usr/bin/docker start hhe3x
  /usr/bin/docker start ghh3x
  /usr/bin/docker start hbh3x
  /usr/bin/docker start mes3x
  /usr/bin/docker start phs3x
  /usr/bin/docker start pes3x
  /usr/bin/docker start ves3x-test
  /usr/bin/docker start vge3x
  /usr/bin/docker start hrm3x
  /usr/bin/docker start kpm3x
  /usr/bin/docker start kms3x
  /usr/bin/docker start pools3x
  /usr/bin/docker start facilities3x
end script  

Simply add the name of your container prepended by /usr/bin/docker start before the end of the script.

That should be it for now!