Running Docker Inside A LXC Container - Bridged to existing LAN

My LXD host is running Ubuntu 17.04.  I created a bridged interface and set that interface as the default network for all LXD containers...  This results in my containers being on my LAN..  This works just fine, however, I'm now trying to run Docker inside a LXD container.  My goal is to place all Docker container on the same LAN.  How can I create a Docker network to be on the same LAN while nested on a LXD container?
gopher_49Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
First, I'm unsure why you'd dockerize your apps since your running a container already.

Simple solution is don't run docker. You're already containered using LXD.

That said, if I had to debug this, I'd first check my networking in my docker container.

Likely it's some minor routing problem. You'll have to arrange for your packets to flow through your LXD network stack to your machine network stack.

How this is done is highly dependent on all commands you issued to get to where you are now.

Also, keep in mind, all work you do on Zesty, will likely require a complete rethink, when you upgrade to Artful or Bionic, as both these scrape current networking + switch to using netplan (shudder).

If at all possible, skip docker + just run your application native in LXD.

If you must run docker, then install tshark... let's see... I'd likely install it at machine level + compare how packet flow was working from LXD to machine + how it was broken when flowing from docker to LXD.
gopher_49Author Commented:
The thing is this..  Developers/vendors sometimes ship applications via Docker... I can run one command and deploy a complex application..  Now..  Docker natively is a problem for me..  This being due to the fact on one VM I wish to run a different versions of different PHP, MySQL, and even different VLANs/networks...  So.. This is where LXD containers make sense..  The perfect scenario will be to run LXD containers and then pull Docker images down to in return create Docker containers nested in  a LXD container.  I'll build a lab for this.. I have a use case...
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
https://stgraber.org/2016/04/13/lxd-2-0-docker-in-lxd-712 provides some good starting detail.

And, likely still be easier just to load your applications directly into an LXD container.

This means you'd use apt-get to install the package, rather than to install a dockerized app.

My guess is dockerized apps will tend to lag Distro packages for security + enhancement fixes.

To accomplish different versions of different PHP, MySQL, and even different VLANs/networks... will require a tremendous amount of work, because you're trying to duplicate the relationship between machine Distro + LXD containers, inside a container.

Another problem you'll have to surmount is managing wiring your dockerized apps together.

If you run 8 copies of various MySQL/Apache/PHP combinations, you'll have to tool up a custom method for starting each pipeline at reboot + also when bounced (stop/restart) while container is still running.

This still sounds like a huge amount of work for what LXD already does.

In the LXD case, you'd spin up a separate container for each unique MySQL/Apache/PHP combo.

I do this every day for clients. Takes a few seconds... so if your work tooling up managing all your dockerized apps inside single containers takes more than a few seconds to get working, you might consider just using LXD without Docker.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gopher_49Author Commented:
After reviewing this further I agree 100%.  If I have a Developer that wants to work in docker I'll spin up a dedicated VM for his use... That single VM will be for his docker apps..  I'll create my own registry and the developer can package and ship directly to me across the datacenters securely.  Other than that I'm sticking with LXD containers.  They are awesome...  I already moved 4 x network appliances and my Atlassian Confluence app within one VM that is the LXD host. I saved 6 GBs of RAM already..  And..  It's easier to manage for in the past I would have to add each VM to my VEEAM tape backup job, VEEAM disk to disk job, and Nimble Storage snapshot job.  I have so many VMs it becomes hard to manage.  This one LXD host will end up hosting 10+ network appliances and my Atlassian Confluence app...  I built a series of bridged NICs that present the container to their respective vSwitch in vSphere.  I don't see any performance hit either...  Now..  In my other environments where I don't have Hypervisor access I'll be able to create my own nested Hypervisor and give myself an experience I didn't have before...  This being environments where I lease VMs on a per month basis...  The fact I'll be able to take snapshots nested on someone else's Hypervisor is golden...  In the past I would have to open a ticket with the data center and request a snapshot for ease of roll back...  In addition to that no more creating VMs on their Hypervisor...  I'll just spin up a container..  I love it...  LXD is amazing and to be honest so is Windows Containers.  Once their Linux kit is in production I'll be doing a lot in Windows Containers...
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Oh certainly yes.

I didn't think you might have been referring to some developer asking for this type of setup.

Yep, for me LXD resolved all my client hosting problems + allows me to run a large hosting company with a handful of people.

Before LXD, if one site had run away resource usage, determine the site + exact problem was complex + time consuming.

With LXD, these types of problems tend to be faster + simpler to resolve.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
LXC

From novice to tech pro — start learning today.