Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I want to execute a command inside an existing lxc without going through the regular Linux init. lxc-execute command is for that I guess but I get the following error when I run this command on my existing test lxc.

sudo lxc-execute -n test -- service apache2 start 

I get following error:

lxc-execute: Failed to find an lxc-init
lxc-execute: invalid sequence number 1. expected 4
lxc-execute: failed to spawn 'test'
share|improve this question

2 Answers 2

Have you tried lxc-attach instead? According the documentation,

lxc-attach - start a process inside a running container.

Example to list all folders inside home of the container

lxc-attach -n myContainer -- ls -lh /home

If no process is defined, it creates a new shell inside the container.

share|improve this answer

lxc-execute is designed to create and run and lxc container and execute the command. So it can not be used to execute a command currently setup and started one.

Quotation from Serge E. Hallyn @ https://www.mail-archive.com/lxc-users@lists.sourceforge.net/msg00134.html

Moving an existing process into an existing, populated namespace will likely never be possible.

You may try Ullrich Horlacher's lxc command but currently the page is out of order. Process is described in this post:

https://www.mail-archive.com/lxc-users@lists.sourceforge.net/msg01970.html

share|improve this answer

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.