[nSLUG] Any Docker experts on this thread?

Brad Chivari bchivari at gmail.com
Wed Jul 26 12:21:05 ADT 2017


Hey Stephen,

I'll try to take a crack at it...

As Evan pointed out, the 12 Factor approach outlines a lot of best
practices when it comes to this sort of deployment.

Generally though, you want to keep your containers stateless and where
application state or persistence to disk is required (ie. a Database, a
web-tree, configuration files) these get attached to a generic image as
volumes (in various flavors).

I'm not sure why you'd every have to mount the volumes from, say a DB
container, into the Wordpress container. Wouldn't you be interacting with
the database via a TCP client? If so, your application shouldn't need
access to the volume/filesystem of the database container.

Most database images provide a "/docker-entrypoint-initdb.d" type folder
that will be scanned on container launch if the DB isn't initialized. It
will read all .sh or .sql files at that path and execute them to do things
like deploy a schema or tweak configuration. The other alternative
(probably more suited to wordpress) is to allow the application to detect
whether the database it's liked to (over the network) has been initialized
and then take action to self-deploy it's schema if not. Basically point
your app at the generic database and it will unfurl it's schema.

The path where your database stores its data, /var/lib/mysql, should be a
volume / attached volume / data-only container.... What this amounts to is
your database container is generic and is stateless--you can completely
remove the container and create a new one while persistence is provided by
pointing that generic container at the attached /var/lib/mysql volume.

I'll send you a PM if you wanted to talk though anything docker related as
it may be easier that typing it out. :)

-
Brad


On Wed, Jul 26, 2017 at 12:18 PM, <nslug-request at nslug.ns.ca> wrote:

> Message: 2
> Date: Tue, 25 Jul 2017 19:06:03 -0300
> From: Stephen Yorke <syorke at gmail.com>
> To: Nova Scotia Linux User Group <nslug at nslug.ns.ca>
> Subject: [nSLUG] Any Docker experts on this thread?
> Message-ID:
>         <CANxzGRrXX_aYn7iiXUeGNu0BFQr+NU1uWxMAH-6YO9rfbeEMoQ at mail.gm
> ail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Howdy again gang,
>
> Have a couple things I want to run by someone who is at least good in
> Docker.
>
> I am setting up a new web infrastructure which will mainly be WordPress
> sites but I want to do it all in Docker and have some questions and
> possible concerns.
>
> 1. The MySQL/MariaDB instance
> Should I create my DB instance on a stand-alone DB server which would also
> run NGINX and WordPress to do the initial configurations, then using
> Docker, mount the MySQL folder to each container?
>
> 2. WordPress
> If using the above server as my 'base' for configuration, could I then
> mount its WordPress folder as well to each Container or is there a better
> way of doing so?
>
> 3. NGINX
> I will be using the latest stable version NGINX and php-fpm, mount the
> folders in containers as well or just setup my NGINX container, copy the
> NGINX config files to the local host and have Docker mount said local
> folders for the NGINX instance?
>
> I will be looking at Docker Swarm to setup multiple instances of the
> websites eventually and have auto-expand and auto-deplete depending on
> load.  I will probably have a total of 3-5 Docker nodes running possibly
> RanchOS, CoreOS or AlpineOS as I do not need a full Debian installation to
> be used as my Container OSes but I will be using Debian or CentOS for my
> Database server and possibly another for a File Server for
> sharing/mounting to the Docker nodes.
>
> Mainly, what I am looking for is a best practice for the above areas.  I
> have looked online but can not find anything really for the database side
> of things.  There is a lot of partial information but no type of guides,
> guidelines or walk-throughs that folks have already done.  I am sure folks
> running these types of setups have done all of the above, why is there real
> no information on it out there?  If I get it all setup and configured, it
> will be one of the first blog posts I publish on some site somewhere.
>
> Thanks in advance for any and all replies, even if it is just links to
> documentation that I have yet to uncover.
> -Stephen
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://nslug.ns.ca/pipermail/nslug/attachments/20170725/98b
> 7c4e1/attachment-0001.html>
>
> ------------------------------
>
> Message: 3
> Date: Tue, 25 Jul 2017 19:19:01 -0300
> From: Evan Lowry <lowry.e at gmail.com>
> To: Nova Scotia Linux User Group <nslug at nslug.ns.ca>
> Subject: Re: [nSLUG] Any Docker experts on this thread?
> Message-ID:
>         <CACkQtJ3+S8wQoiPVWuTTO6qabrzir=+9CheLQ2oBJujUkUTcaw at mail.
> gmail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Following 12 factor will save you loads of headache when it comes to using
> containers: https://12factor.net/
>
> If we ignore data persistence problems for a moment, typically you would
> have a docker-compose file with 2-3 services defined in this case:
> - mysql
> - nginx
> - whatever your php runner is (assuming it's like uwsgi for python, I'm
> willfully blind to PHP land)
>
> The nginx container has exposed public ports, which you connect into, the
> others just act as attached resources.
>
> If you need to run one-time migration style scripts, typically you would
> just launch a second php runner instance with the already running database
> node attached post-deployment (application should handle unconfigured state
> gracefully).
>
> If this is going to be a production setup, data persistence is a concern --
> I did all my docker setup back in the 1.0.3 days, the data volume API
> wasn't an option (and just used RDS or flocker instead). It might be good,
> but I haven't used it personally:
> https://docs.docker.com/engine/reference/commandline/volume_create/
>
> Wordpress has been one of their docker-compose samples for quite some time,
> which may be a good reference: https://docs.docker.com/samples/wordpress/
>
> Hope some of that helps,
> - Evan
>
> On Tue, Jul 25, 2017 at 7:06 PM, Stephen Yorke <syorke at gmail.com> wrote:
>
> > Howdy again gang,
> >
> > Have a couple things I want to run by someone who is at least good in
> > Docker.
> >
> > I am setting up a new web infrastructure which will mainly be WordPress
> > sites but I want to do it all in Docker and have some questions and
> > possible concerns.
> >
> > 1. The MySQL/MariaDB instance
> > Should I create my DB instance on a stand-alone DB server which would
> also
> > run NGINX and WordPress to do the initial configurations, then using
> > Docker, mount the MySQL folder to each container?
> >
> > 2. WordPress
> > If using the above server as my 'base' for configuration, could I then
> > mount its WordPress folder as well to each Container or is there a better
> > way of doing so?
> >
> > 3. NGINX
> > I will be using the latest stable version NGINX and php-fpm, mount the
> > folders in containers as well or just setup my NGINX container, copy the
> > NGINX config files to the local host and have Docker mount said local
> > folders for the NGINX instance?
> >
> > I will be looking at Docker Swarm to setup multiple instances of the
> > websites eventually and have auto-expand and auto-deplete depending on
> > load.  I will probably have a total of 3-5 Docker nodes running possibly
> > RanchOS, CoreOS or AlpineOS as I do not need a full Debian installation
> to
> > be used as my Container OSes but I will be using Debian or CentOS for my
> > Database server and possibly another for a File Server for
> > sharing/mounting to the Docker nodes.
> >
> > Mainly, what I am looking for is a best practice for the above areas.  I
> > have looked online but can not find anything really for the database side
> > of things.  There is a lot of partial information but no type of guides,
> > guidelines or walk-throughs that folks have already done.  I am sure
> folks
> > running these types of setups have done all of the above, why is there
> real
> > no information on it out there?  If I get it all setup and configured, it
> > will be one of the first blog posts I publish on some site somewhere.
> >
> > Thanks in advance for any and all replies, even if it is just links to
> > documentation that I have yet to uncover.
> > -Stephen
> >
> > _______________________________________________
> > nSLUG mailing list
> > nSLUG at nslug.ns.ca
> > http://nslug.ns.ca/mailman/listinfo/nslug
> >
> >
>
>
> --
> Evan Lowry
> 902.403.5244
> www.exitiumonline.com | https://github.com/Lykathia
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://nslug.ns.ca/pipermail/nslug/attachments/20170725/b96
> 38bbc/attachment-0001.html>
>
> ------------------------------
>
> Message: 4
> Date: Wed, 26 Jul 2017 09:06:23 -0300
> From: Stephen Yorke <syorke at gmail.com>
> To: Nova Scotia Linux User Group <nslug at nslug.ns.ca>
> Subject: Re: [nSLUG] Any Docker experts on this thread?
> Message-ID:
>         <CANxzGRoGxpTpdiaL9bhWHz8UQgudcfgvzm2pZ1+SR7PzAbRFzQ at mail.gm
> ail.com>
> Content-Type: text/plain; charset="utf-8"
>
> Thanks for the information Evan.
>
> Time to start digging.  =)
>
> On Tue, Jul 25, 2017 at 7:19 PM, Evan Lowry <lowry.e at gmail.com> wrote:
>
> > Following 12 factor will save you loads of headache when it comes to
> using
> > containers: https://12factor.net/
> >
> > If we ignore data persistence problems for a moment, typically you would
> > have a docker-compose file with 2-3 services defined in this case:
> > - mysql
> > - nginx
> > - whatever your php runner is (assuming it's like uwsgi for python, I'm
> > willfully blind to PHP land)
> >
> > The nginx container has exposed public ports, which you connect into, the
> > others just act as attached resources.
> >
> > If you need to run one-time migration style scripts, typically you would
> > just launch a second php runner instance with the already running
> database
> > node attached post-deployment (application should handle unconfigured
> state
> > gracefully).
> >
> > If this is going to be a production setup, data persistence is a concern
> > -- I did all my docker setup back in the 1.0.3 days, the data volume API
> > wasn't an option (and just used RDS or flocker instead). It might be
> good,
> > but I haven't used it personally: https://docs.
> > docker.com/engine/reference/commandline/volume_create/
> >
> > Wordpress has been one of their docker-compose samples for quite some
> > time, which may be a good reference: https://docs.
> > docker.com/samples/wordpress/
> >
> > Hope some of that helps,
> > - Evan
> >
> > On Tue, Jul 25, 2017 at 7:06 PM, Stephen Yorke <syorke at gmail.com> wrote:
> >
> >> Howdy again gang,
> >>
> >> Have a couple things I want to run by someone who is at least good in
> >> Docker.
> >>
> >> I am setting up a new web infrastructure which will mainly be WordPress
> >> sites but I want to do it all in Docker and have some questions and
> >> possible concerns.
> >>
> >> 1. The MySQL/MariaDB instance
> >> Should I create my DB instance on a stand-alone DB server which would
> >> also run NGINX and WordPress to do the initial configurations, then
> using
> >> Docker, mount the MySQL folder to each container?
> >>
> >> 2. WordPress
> >> If using the above server as my 'base' for configuration, could I then
> >> mount its WordPress folder as well to each Container or is there a
> better
> >> way of doing so?
> >>
> >> 3. NGINX
> >> I will be using the latest stable version NGINX and php-fpm, mount the
> >> folders in containers as well or just setup my NGINX container, copy the
> >> NGINX config files to the local host and have Docker mount said local
> >> folders for the NGINX instance?
> >>
> >> I will be looking at Docker Swarm to setup multiple instances of the
> >> websites eventually and have auto-expand and auto-deplete depending on
> >> load.  I will probably have a total of 3-5 Docker nodes running possibly
> >> RanchOS, CoreOS or AlpineOS as I do not need a full Debian installation
> to
> >> be used as my Container OSes but I will be using Debian or CentOS for my
> >> Database server and possibly another for a File Server for
> >> sharing/mounting to the Docker nodes.
> >>
> >> Mainly, what I am looking for is a best practice for the above areas.  I
> >> have looked online but can not find anything really for the database
> side
> >> of things.  There is a lot of partial information but no type of guides,
> >> guidelines or walk-throughs that folks have already done.  I am sure
> folks
> >> running these types of setups have done all of the above, why is there
> real
> >> no information on it out there?  If I get it all setup and configured,
> it
> >> will be one of the first blog posts I publish on some site somewhere.
> >>
> >> Thanks in advance for any and all replies, even if it is just links to
> >> documentation that I have yet to uncover.
> >> -Stephen
> >>
> >> _______________________________________________
> >> nSLUG mailing list
> >> nSLUG at nslug.ns.ca
> >> http://nslug.ns.ca/mailman/listinfo/nslug
> >>
> >>
> >
> >
> > --
> > Evan Lowry
> > 902.403.5244 <(902)%20403-5244>
> > www.exitiumonline.com | https://github.com/Lykathia
> >
> > _______________________________________________
> > nSLUG mailing list
> > nSLUG at nslug.ns.ca
> > http://nslug.ns.ca/mailman/listinfo/nslug
> >
> >
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL: <http://nslug.ns.ca/pipermail/nslug/attachments/20170726/6bc
> f25a3/attachment.html>
>
> ------------------------------
>
> Subject: Digest Footer
>
> _______________________________________________
> nSLUG mailing list
> nSLUG at nslug.ns.ca
> http://nslug.ns.ca/mailman/listinfo/nslug
>
>
> ------------------------------
>
> End of nSLUG Digest, Vol 779, Issue 1
> *************************************
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://nslug.ns.ca/pipermail/nslug/attachments/20170726/2e3fc32c/attachment-0001.html>


More information about the nSLUG mailing list