Jump to content

ubuntu lxd containers


rev.dennis
 Share

Recommended Posts

Here are some notes regarding using containers in Ubuntu via lxd

Install was pretty simple since lxd said it was already installed when I tried to run sudo apt-get install lxd

I got no errors running: newgrp lxd

Also no errors running: sudo lxd init

So you must have some images to create lxd instances.. Here is a manual way of adding an image to the image store

lxc image import <file> --alias <name>

If you want to see a list of images you can simply run: lxc image list images:

By default lxd comes with three image stores built in

  1. ubuntu: (for stable Ubuntu images)
  2. ubuntu-daily: (for daily Ubuntu images)
  3. images: (for a bunch of other distros)

So if you wanted to check out what images are available at the default image stores you could run

  1. lxc image list ubuntu:
  2. lxc image list ubuntu-daily:
  3. lxc image list images:

Once you found an image you would like to install you simply type in:

  1. lxc launch ubuntu:14.04 my-ubuntu
  2. lxc launch ubuntu-daily:16.04 my-ubuntu-dev
  3. lxc launch images:centos/6/amd64 my-centos

But let's say you already have an image and its not on one of these stores.  This is how you import it

  • Import it with: lxc image import \<file\> --alias my-alias
  • Run it with: lxc launch my-alias my-container

Now if you wanted to run a command against one of your containers (let's say my-ubuntu that you created above) you would run: lxc exec my-ubuntu -- /bin/bash

Here are some other examples:

  • lxc exec my-ubuntu -- apt-get update
  • lxc file pull my-ubuntu /etc/hosts .
  • lxc file push hosts my-ubuntu /tmp/

You may want to stop the container and to do so you would run: lxc stop my-ubuntu

And to delete the container: lxc delete my-ubuntu

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...