0

I have a question about LXC Containers.

I have some containers, if I lxc-start them, they come up with networking fine, but I want to just be able to run commands against them using lxc-execute, without starting the whole thing. However, when I do this, there is no connectivity? - I guess as doesnt run init. How can I fix this?

user49411
  • 1
  • 1

1 Answers1

0

You're right, the network is not setup because lxc-execute just creates the container and runs your application. lxc-start runs /sbin/init, which takes care of the nitty-gritty.

You can use a script that sets up networking and then executes whatever you give it as the first parameter, something like:

ifup -a
if [ -x "$1" ]; then
    exec "$1"
fi
echo "Something went wrong."

You could also configure the network parameters in the container configuration. In this case LXC will set up the network before it runs your application.

Borut Mrak
  • 21
  • 2