Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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 10.0.3.123:22

(forwards port 2022 on eth0 to the container with IP 10.0.3.123 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.

share|improve this answer
    
Copying directly to the container and chowning to the correct nummeric uid and gid worked perfectly. Thank you. –  Repox Jan 8 at 21:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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