Discussion:
How to auto-start LXC containers with LXD
(too old to reply)
Ozan Hazer
2015-05-05 10:53:54 UTC
Permalink
Hi,

How do I configure LXC containers so that it'll start automatically in
Ubuntu 15.04 and LXD?
Ubuntu documentation states that the containers with the configuration
lxc.start.auto=1 will be started on boot however I couldn't find the config
file for the container.

Thanks,
M.Ozan Hazer
Serge Hallyn
2015-05-05 14:00:57 UTC
Permalink
Post by Ozan Hazer
Hi,
How do I configure LXC containers so that it'll start automatically in
Ubuntu 15.04 and LXD?
Ubuntu documentation states that the containers with the configuration
lxc.start.auto=1 will be started on boot however I couldn't find the config
file for the container.
For default privileged containers the config file is
/var/lib/lxc/$containername/config
Andrey Repin
2015-05-05 16:24:52 UTC
Permalink
Greetings, Serge Hallyn!
Post by Serge Hallyn
Post by Ozan Hazer
How do I configure LXC containers so that it'll start automatically in
Ubuntu 15.04 and LXD?
Ubuntu documentation states that the containers with the configuration
lxc.start.auto=1 will be started on boot however I couldn't find the config
file for the container.
For default privileged containers the config file is
/var/lib/lxc/$containername/config
He did meantion LXD explicitly.
There's no "config" in LXD containers. Which I find a certain deficiency of
the design. If I can't get a backup of entire container together with config,
it has no use for me.
--
With best regards,
Andrey Repin
Tuesday, May 5, 2015 19:23:34

Sorry for my terrible english...
Ozan Hazer
2015-05-06 08:46:54 UTC
Permalink
Yeah, I wish I realized that before setting up everything :\
I agree with the central configuration thing, it reduces the portability
too at first glance. However not sure if it should be considered as a
deficiency...
lxd is designed this way and instead of manually doing things (copying
etc.) it provides tools for it which attracted me in the first place. I can
do what lxd does with lxc-* commands already but lxd is much easier to use
and gives the feeling of vagrant and docker.
There is lxc copy and move and I bet (or hope?) there will be some export
or backup command in the future... The configurations are kept in sqlite
(/var/lib/lxd/lxd.db) so extracting the config should not be that hard
(hope again :) )

The problem that hit me is lxd is apparently is not mature enough and the
announcement that ubuntu made and advertised misleaded me since I'm a
developer and not following server technologies closely.

For the auto-startup issue I ended up with writing a systemd job for
startup and I guess I'll need smt. else for a clean shutdown too... I have
atlassian products (jira & stash) running inside the container and they are
not starting for some reason... Still investigating...
---------- Forwarded message ----------
Date: Tue, 5 May 2015 19:24:52 +0300
Subject: Re: [lxc-users] How to auto-start LXC containers with LXD
Greetings, Serge Hallyn!
Post by Serge Hallyn
Post by Ozan Hazer
How do I configure LXC containers so that it'll start automatically in
Ubuntu 15.04 and LXD?
Ubuntu documentation states that the containers with the configuration
lxc.start.auto=1 will be started on boot however I couldn't find the
config
Post by Serge Hallyn
Post by Ozan Hazer
file for the container.
For default privileged containers the config file is
/var/lib/lxc/$containername/config
He did meantion LXD explicitly.
There's no "config" in LXD containers. Which I find a certain deficiency of
the design. If I can't get a backup of entire container together with
config,
it has no use for me.
--
With best regards,
Andrey Repin
Tuesday, May 5, 2015 19:23:34
Sorry for my terrible english...
M.Ozan Hazer
Stéphane Graber
2015-05-06 09:27:56 UTC
Permalink
Post by Ozan Hazer
Yeah, I wish I realized that before setting up everything :\
I agree with the central configuration thing, it reduces the portability
too at first glance. However not sure if it should be considered as a
deficiency...
lxd is designed this way and instead of manually doing things (copying
etc.) it provides tools for it which attracted me in the first place. I can
do what lxd does with lxc-* commands already but lxd is much easier to use
and gives the feeling of vagrant and docker.
There is lxc copy and move and I bet (or hope?) there will be some export
or backup command in the future... The configurations are kept in sqlite
(/var/lib/lxd/lxd.db) so extracting the config should not be that hard
(hope again :) )
It's really a different design. For LXD we want more input validation,
we want to be able to inherit from profiles and we generally need to
store more complex constructs than can be stored in the LXC config file.

So that and speed (it turns out opening and reading thousands of files
isn't very quick) is what made us use a database.

While it's not in our immediate roadmap, commands to import/export
containers as we do images may be a possibility and may be covering your
needs.
Post by Ozan Hazer
The problem that hit me is lxd is apparently is not mature enough and the
announcement that ubuntu made and advertised misleaded me since I'm a
developer and not following server technologies closely.
Not sure how our announcement is misleading...

For the Ubuntu 15.04 announcement, I wrote:

"""
Ubuntu 15.04 ships with LXD 0.7. This is the result of an intense 6
months of development and while not ready for production workloads, it's
definitely ready for experimentation.
"""

And upstream, outside of bugfix-only releases, we've always included
this in our announcements:

"""
Please note that it's still early in the LXD development and that
current LXD isn't intended for production use and comes with no support
statement from upstream.
(reported bugs and patches will be included in the next release)
"""
Post by Ozan Hazer
For the auto-startup issue I ended up with writing a systemd job for
startup and I guess I'll need smt. else for a clean shutdown too... I have
atlassian products (jira & stash) running inside the container and they are
not starting for some reason... Still investigating...
Getting the power state stuff done shouldn't be too difficult. I believe
we already have the DB field, so all that's needed is code to attach the
SIGPWR signal with a shutdown function which stops all containers and
mark their states in the power_state field, then another function run at
startup just needs to read the power_state field, start any container
that's set to 1 and then unset the field.

We'd certainly welcome a branch for that.
Post by Ozan Hazer
---------- Forwarded message ----------
Date: Tue, 5 May 2015 19:24:52 +0300
Subject: Re: [lxc-users] How to auto-start LXC containers with LXD
Greetings, Serge Hallyn!
Post by Serge Hallyn
Post by Ozan Hazer
How do I configure LXC containers so that it'll start automatically in
Ubuntu 15.04 and LXD?
Ubuntu documentation states that the containers with the configuration
lxc.start.auto=1 will be started on boot however I couldn't find the
config
Post by Serge Hallyn
Post by Ozan Hazer
file for the container.
For default privileged containers the config file is
/var/lib/lxc/$containername/config
He did meantion LXD explicitly.
There's no "config" in LXD containers. Which I find a certain deficiency of
the design. If I can't get a backup of entire container together with
config,
it has no use for me.
--
With best regards,
Andrey Repin
Tuesday, May 5, 2015 19:23:34
Sorry for my terrible english...
M.Ozan Hazer
_______________________________________________
lxc-users mailing list
http://lists.linuxcontainers.org/listinfo/lxc-users
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
Ozan Hazer
2015-05-06 16:20:22 UTC
Permalink
Ah it was more like the page about lxd, not the announcement...
Announcements expire you know and I didn't check how up-to-date it was...
I couldn't express it well I think, I mean I misinterpreted the page that
was just advertising the lxd (http://www.ubuntu.com/cloud/tools/lxd).
I missed the fact that it's not mature yet and dived into it that's what I
was trying to say...
---------- Forwarded message ----------
Date: Wed, 6 May 2015 11:27:56 +0200
Subject: Re: [lxc-users] How to auto-start LXC containers with LXD
Post by Ozan Hazer
Yeah, I wish I realized that before setting up everything :\
I agree with the central configuration thing, it reduces the portability
too at first glance. However not sure if it should be considered as a
deficiency...
lxd is designed this way and instead of manually doing things (copying
etc.) it provides tools for it which attracted me in the first place. I
can
Post by Ozan Hazer
do what lxd does with lxc-* commands already but lxd is much easier to
use
Post by Ozan Hazer
and gives the feeling of vagrant and docker.
There is lxc copy and move and I bet (or hope?) there will be some export
or backup command in the future... The configurations are kept in sqlite
(/var/lib/lxd/lxd.db) so extracting the config should not be that hard
(hope again :) )
It's really a different design. For LXD we want more input validation,
we want to be able to inherit from profiles and we generally need to
store more complex constructs than can be stored in the LXC config file.
So that and speed (it turns out opening and reading thousands of files
isn't very quick) is what made us use a database.
While it's not in our immediate roadmap, commands to import/export
containers as we do images may be a possibility and may be covering your
needs.
Post by Ozan Hazer
The problem that hit me is lxd is apparently is not mature enough and the
announcement that ubuntu made and advertised misleaded me since I'm a
developer and not following server technologies closely.
Not sure how our announcement is misleading...
"""
Ubuntu 15.04 ships with LXD 0.7. This is the result of an intense 6
months of development and while not ready for production workloads, it's
definitely ready for experimentation.
"""
And upstream, outside of bugfix-only releases, we've always included
"""
Please note that it's still early in the LXD development and that
current LXD isn't intended for production use and comes with no support
statement from upstream.
(reported bugs and patches will be included in the next release)
"""
Post by Ozan Hazer
For the auto-startup issue I ended up with writing a systemd job for
startup and I guess I'll need smt. else for a clean shutdown too... I
have
Post by Ozan Hazer
atlassian products (jira & stash) running inside the container and they
are
Post by Ozan Hazer
not starting for some reason... Still investigating...
Getting the power state stuff done shouldn't be too difficult. I believe
we already have the DB field, so all that's needed is code to attach the
SIGPWR signal with a shutdown function which stops all containers and
mark their states in the power_state field, then another function run at
startup just needs to read the power_state field, start any container
that's set to 1 and then unset the field.
We'd certainly welcome a branch for that.
Post by Ozan Hazer
---------- Forwarded message ----------
Date: Tue, 5 May 2015 19:24:52 +0300
Subject: Re: [lxc-users] How to auto-start LXC containers with LXD
Greetings, Serge Hallyn!
Post by Serge Hallyn
Post by Ozan Hazer
How do I configure LXC containers so that it'll start automatically
in
Post by Ozan Hazer
Post by Serge Hallyn
Post by Ozan Hazer
Ubuntu 15.04 and LXD?
Ubuntu documentation states that the containers with the
configuration
Post by Ozan Hazer
Post by Serge Hallyn
Post by Ozan Hazer
lxc.start.auto=1 will be started on boot however I couldn't find the
config
Post by Serge Hallyn
Post by Ozan Hazer
file for the container.
For default privileged containers the config file is
/var/lib/lxc/$containername/config
He did meantion LXD explicitly.
There's no "config" in LXD containers. Which I find a certain
deficiency of
Post by Ozan Hazer
the design. If I can't get a backup of entire container together with
config,
it has no use for me.
--
With best regards,
Andrey Repin
Tuesday, May 5, 2015 19:23:34
Sorry for my terrible english...
M.Ozan Hazer
_______________________________________________
lxc-users mailing list
http://lists.linuxcontainers.org/listinfo/lxc-users
--
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
_______________________________________________
lxc-users mailing list
http://lists.linuxcontainers.org/listinfo/lxc-users
M.Ozan Hazer
Kevin LaTona
2015-05-08 19:35:54 UTC
Permalink
So far LXD is not working for me, is it working for you?

In a nutshell I downloaded new Ubuntu 15.04 server.

Installed this on fresh clean server, nothing else is on this machine.

I followed Stephane's blog post here line by line

https://www.stgraber.org/2015/04/21/lxd-getting-started/

After several days of attempts I get nothing but errors.


This is an example of the last attempt.

lxc launch images:ubuntu/trusty/i386 ubuntu-32
Creating container...error: Get http://unix.socket/1.0: dial unix /var/lib/lxd/unix.socket: connection refused



So my question is not that I am looking for direct answers to the problem.

Rather what I am looking for what now is.

Has anyone else taken a clean server and installed 15.04 and LDX on it using the current apt-get calls.


If you are getting it to work under this kind of install, can you point me to any web based docs that shows how you did that?


Thanks
-Kevin
Tycho Andersen
2015-05-09 00:06:13 UTC
Permalink
Post by Kevin LaTona
So far LXD is not working for me, is it working for you?
In a nutshell I downloaded new Ubuntu 15.04 server.
Installed this on fresh clean server, nothing else is on this machine.
I followed Stephane's blog post here line by line
https://www.stgraber.org/2015/04/21/lxd-getting-started/
After several days of attempts I get nothing but errors.
This is an example of the last attempt.
lxc launch images:ubuntu/trusty/i386 ubuntu-32
Creating container...error: Get http://unix.socket/1.0: dial unix /var/lib/lxd/unix.socket: connection refused
Looks like LXD isn't running. What if you start it and try again?

sudo service lxd start

Tycho
Post by Kevin LaTona
So my question is not that I am looking for direct answers to the problem.
Rather what I am looking for what now is.
Has anyone else taken a clean server and installed 15.04 and LDX on it using the current apt-get calls.
If you are getting it to work under this kind of install, can you point me to any web based docs that shows how you did that?
Thanks
-Kevin
_______________________________________________
lxc-users mailing list
http://lists.linuxcontainers.org/listinfo/lxc-users
Serge Hallyn
2015-05-09 00:23:50 UTC
Permalink
Post by Tycho Andersen
Post by Kevin LaTona
So far LXD is not working for me, is it working for you?
In a nutshell I downloaded new Ubuntu 15.04 server.
Installed this on fresh clean server, nothing else is on this machine.
I followed Stephane's blog post here line by line
https://www.stgraber.org/2015/04/21/lxd-getting-started/
After several days of attempts I get nothing but errors.
This is an example of the last attempt.
lxc launch images:ubuntu/trusty/i386 ubuntu-32
Creating container...error: Get http://unix.socket/1.0: dial unix /var/lib/lxd/unix.socket: connection refused
Looks like LXD isn't running. What if you start it and try again?
Disagree, it would say "no such file or directory". It looks to
me like he's not in the lxd group.
Matt
2015-05-09 01:57:00 UTC
Permalink
I installed a new 15.04 this week and have the same problem.
For me starting the LXD daemon solves the problem until the next reboot.
sudo systemctl start lxd

I haven't explored the issue, but I think I saw a post from stgraber saying he was aware of problems with the 15.04 start scripts.
Post by Serge Hallyn
Post by Tycho Andersen
Post by Kevin LaTona
So far LXD is not working for me, is it working for you?
In a nutshell I downloaded new Ubuntu 15.04 server.
Installed this on fresh clean server, nothing else is on this machine.
I followed Stephane's blog post here line by line
https://www.stgraber.org/2015/04/21/lxd-getting-started/
After several days of attempts I get nothing but errors.
This is an example of the last attempt.
lxc launch images:ubuntu/trusty/i386 ubuntu-32
Creating container...error: Get http://unix.socket/1.0: dial unix /var/lib/lxd/unix.socket: connection refused
Looks like LXD isn't running. What if you start it and try again?
Disagree, it would say "no such file or directory". It looks to
me like he's not in the lxd group.
Tycho Andersen
2015-05-09 15:24:43 UTC
Permalink
Post by Serge Hallyn
Post by Tycho Andersen
Post by Kevin LaTona
So far LXD is not working for me, is it working for you?
In a nutshell I downloaded new Ubuntu 15.04 server.
Installed this on fresh clean server, nothing else is on this machine.
I followed Stephane's blog post here line by line
https://www.stgraber.org/2015/04/21/lxd-getting-started/
After several days of attempts I get nothing but errors.
This is an example of the last attempt.
lxc launch images:ubuntu/trusty/i386 ubuntu-32
Creating container...error: Get http://unix.socket/1.0: dial unix /var/lib/lxd/unix.socket: connection refused
Looks like LXD isn't running. What if you start it and try again?
Disagree, it would say "no such file or directory". It looks to
me like he's not in the lxd group.
It depends on what state you're in. Connection refused means the
socket exists but nothing is listening on the other end (likely lxd
crashed or wasn't shut down properly). If the socket doesn't exist,
you'll get an ENOENT.

Tycho
Post by Serge Hallyn
lxc-users mailing list
http://lists.linuxcontainers.org/listinfo/lxc-users
Kevin LaTona
2015-05-10 01:26:15 UTC
Permalink
What is unclear to me is when LXD is installed on a new server.

Does it create the necessary upstart script to run on the next boot?

Or does LXD need to be ( or prefered to be ) manually run after a server boot?

Or is it up to the user to decide on and create the upstart script to start during boot process etc.

-Kevin
Post by Tycho Andersen
Post by Serge Hallyn
Post by Tycho Andersen
Post by Kevin LaTona
So far LXD is not working for me, is it working for you?
In a nutshell I downloaded new Ubuntu 15.04 server.
Installed this on fresh clean server, nothing else is on this machine.
I followed Stephane's blog post here line by line
https://www.stgraber.org/2015/04/21/lxd-getting-started/
After several days of attempts I get nothing but errors.
This is an example of the last attempt.
lxc launch images:ubuntu/trusty/i386 ubuntu-32
Creating container...error: Get http://unix.socket/1.0: dial unix /var/lib/lxd/unix.socket: connection refused
Looks like LXD isn't running. What if you start it and try again?
Disagree, it would say "no such file or directory". It looks to
me like he's not in the lxd group.
It depends on what state you're in. Connection refused means the
socket exists but nothing is listening on the other end (likely lxd
crashed or wasn't shut down properly). If the socket doesn't exist,
you'll get an ENOENT.
Tycho
Post by Serge Hallyn
lxc-users mailing list
http://lists.linuxcontainers.org/listinfo/lxc-users
_______________________________________________
lxc-users mailing list
http://lists.linuxcontainers.org/listinfo/lxc-users
Serge Hallyn
2015-05-11 23:55:50 UTC
Permalink
Post by Kevin LaTona
What is unclear to me is when LXD is installed on a new server.
Does it create the necessary upstart script to run on the next boot?
Or does LXD need to be ( or prefered to be ) manually run after a server boot?
It's supposed to be, but there was a bug under systemd:
https://github.com/lxc/lxd/issues/550

Kevin LaTona
2015-05-09 01:10:42 UTC
Permalink
Whew…… Tycho Thanks……...okay now it's making some progress for me….. got it going so far.




This is what I found out over the last few days in case anyone else ends up on the same path I was trying to get LDX going.


Following these notes did not work for me https://www.stgraber.org/2015/04/21/lxd-getting-started/ so far.

Maybe I missed something along the way, but after numerous tries all I got was errors with 15.04 + LXC 0.8.1 as of earlier today



When I found these notes today https://linuxcontainers.org/lxd/getting-started-cli/


It appeared changing over to ppa:ubuntu-lxc/lxd-git-master was what was needed to get me going again.




But as it was downloading using lxd-images import lxc ubuntu trusty amd64 --alias ubuntu

I got this traceback message

Traceback (most recent call last):
File "/usr/bin/lxd-images", line 410, in <module>
args.func(parser, args)
File "/usr/bin/lxd-images", line 361, in import_lxc
if fingerprint in lxd.images_list():
File "/usr/bin/lxd-images", line 99, in images_list
status, data = self.rest_call("/1.0/images")
File "/usr/bin/lxd-images", line 70, in rest_call
self.lxd.request(method, path, data)
File "/usr/lib/python3.4/http/client.py", line 1088, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python3.4/http/client.py", line 1126, in _send_request
self.endheaders(body)
File "/usr/lib/python3.4/http/client.py", line 1084, in endheaders
self._send_output(message_body)
File "/usr/lib/python3.4/http/client.py", line 922, in _send_output
self.send(msg)
File "/usr/lib/python3.4/http/client.py", line 857, in send
self.connect()
File "/usr/bin/lxd-images", line 55, in connect
sock.connect(self.path)
ConnectionRefusedError: [Errno 111] Connection refused


I still had no idea why it did that, but it put me dead in the water trying to figure out best next step to take.




Tycho's suggestion of service lxd start seemed to kick start it again.


lxc launch images:ubuntu/trusty/i386 ubuntu-32

Creating container...done
Starting container...done




lxc list
+-----------+---------+------------+------+-----------+-----------+
| NAME | STATE | IPV4 | IPV6 | EPHEMERAL | SNAPSHOTS |
+-----------+---------+------------+------+-----------+-----------+
| ubuntu-32 | RUNNING | 10.0.3.226 | | NO | 0 |
+-----------+---------+------------+------+-----------+-----------+






A few days ago I kept trying to grab images from the linuxcontainers.org server and was getting errors all the time.

lxc remote add images images.linuxcontainers.org
# error: remote images exists as <https://images.linuxcontainers.org:8443>



After one last attempt were I got this
ConnectionRefusedError: [Errno 111] Connection refused



I used curl to try and manually download the image,.

That server which seems like it was bandwidth challenged at the time killed the download with 4MB's to go after 10 minutes of downloading.

curl https://images.linuxcontainers.org:8443/images/ubuntu/trusty/amd64/default/20150503_03:49/lxd.tar.xz -o lxd.tar.xz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
93 64.6M 93 60.1M 0 0 110k 0 0:09:57 0:09:15 0:00:42 33762curl: (18) transfer closed with 4739984 bytes remaining to read






Hopefully others don't use those other document links for images unless I missed something on them.

When I found this link today https://linuxcontainers.org/lxd/getting-started-cli/ as it stands right now it seems likes a better source for a first time test install on LXD.



I wish there was only one source location for all documents on how to get going with LXD.

While it's still so early and not much else on the web yet via google to find on the topic.

But having blog notes and even notes on Ubuntu's site seems like not the best place or way to get folks going on the code if it's old and outdated calls all ready.

No better way to burn out any one is to have documents from what one assumes is one of authority and for it not to work and then have no idea how else to get it going.


Well that's might thoughts on it.

Personally LXC to me just seems like the right way to solve this problem vs all the other ideas that are now floating about.



Finally I did just located this https://github.com/lxc/lxd/blob/master/specs/command-line-user-experience.md

Which for anyone looking for the command calls list here they are.


Hopefully this is making some sense and I am happy to pass along what I found out as I first time installer on LDX as I have about 8 pages of notes from the steps I tried.


Honestly I figured maybe part of the time I might of been missing some key call some and then it choked no idea for sure right now.


But in these Wild, West early days that's darn easy to do and soild good docs to follow when the guys are cranking on getting the code out at the same time is tough.


-Kevin
Post by Tycho Andersen
Post by Kevin LaTona
So far LXD is not working for me, is it working for you?
In a nutshell I downloaded new Ubuntu 15.04 server.
Installed this on fresh clean server, nothing else is on this machine.
I followed Stephane's blog post here line by line
https://www.stgraber.org/2015/04/21/lxd-getting-started/
After several days of attempts I get nothing but errors.
This is an example of the last attempt.
lxc launch images:ubuntu/trusty/i386 ubuntu-32
Creating container...error: Get http://unix.socket/1.0: dial unix /var/lib/lxd/unix.socket: connection refused
Looks like LXD isn't running. What if you start it and try again?
sudo service lxd start
Tycho
Post by Kevin LaTona
So my question is not that I am looking for direct answers to the problem.
Rather what I am looking for what now is.
Has anyone else taken a clean server and installed 15.04 and LDX on it using the current apt-get calls.
If you are getting it to work under this kind of install, can you point me to any web based docs that shows how you did that?
Thanks
-Kevin
_______________________________________________
lxc-users mailing list
http://lists.linuxcontainers.org/listinfo/lxc-users
_______________________________________________
lxc-users mailing list
http://lists.linuxcontainers.org/listinfo/lxc-users
Continue reading on narkive:
Loading...