I'm trying to seperate my database and my PHP application by using LXC.

I'm currently having some issues getting my code deployed to one of the containers - I don't understand how this should work.

My current setup is a VPS which DeployHQ connects to over SSH - uploads the application from GitHub and runs a few commands.

But that solutions doesn't seem possible with my containers - so my question is, what do I do now?

I can get the code to host machine - but how do I get the code to my container while still being sure user permissions on the guest are correct?


The most obvious way is to have LXC behave just like your VPS did. For that you may need to setup a NAT rule on the host which forwards an outside port to the LXC container's port 22.

iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 2022 -j DNAT --to

(forwards port 2022 on eth0 to the container with IP on its port 22).

An alternative is to do it through the host filesystem, there you have two solutions:

  • Copy directly to /var/lib/lxc/CONTAINER/rootfs/...
  • Setup a bind-mount in /var/lib/lxc/CONTAINER/fstab for a path on the host to a path in the container. (e.g. "/srv/site srv/site none bind,ro 0 0" will setup a read-only bind-mount of /srv/site on the host to /srv/site in the container. Both paths must exist prior to container startup.

In both of those cases, you'll need to make sure the ownership matches that in your container, so you'll probably want whatever updates that path on the host do a good old chown -R to the right values.

  • Copying directly to the container and chowning to the correct nummeric uid and gid worked perfectly. Thank you. – Repox Jan 8 '14 at 21:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.