lxclxd

How to automate application deployment when using LXD containers?


How should applications be scripted/automatically deployed when in LXD containers?

For example is best way to deploy applications in LXD containers to use a bash script (which deploys an application)? How to execute this bash script inside the container by executing a command on the host?

Are there any tools/methods of doing this in a similar way to Docker recipes?


Solution

  • In my case, I use Ansible to:

    1. build the LXD containers (web, database, redis for example).
    2. connect to the containers and deploy the services and code needed.

    you can build your own images for example with the services and/or code already deployed and build specific containers from this images.

    I was doing this from before LXD had Ansible support (Ansible 2.2) i prefer to use ssh instead of lxd connection, when i connect to the containers to deploy services/code. they comes with a profile where i had setup my ssh public key (to have direct ssh connection by keys ... no passwords)