[lxc-users] dockerfile equivalent in LXC

Tomasz Chmielewski mangoo at wpkg.org
Tue Oct 4 15:53:13 UTC 2016


On 2016-10-05 00:13, Barve, Yogesh Damodar wrote:
> For creating  a docker container one can use dockerfile to specify all
> the required software installation packages and initialization,
> entrypoint directory and entrypoint command.

LXD or LXC virtualize the whole operating system, so some of these terms 
don't make sense here.


> What will be the equivalent in the LXC world? How can one specify
> - the required packages for installations,

LXD installs a distribution.

For example - this one will install Ubuntu 14.04 ("Trusty"):

lxc launch images:ubuntu/trusty/amd64 some-container-name


Then, to install any packages, you can do:

lxc exec timedoctor-dev apt-get install some-package


> - workdirectory,
> - entrypoint command,

These don't make sense for LXC / LXD.


> - ports to expose and

LXC / LXD behave like proper systems with full networking.

By default, container's IP is "exposed" to the host. What you do with 
it, depends on your usage case.

There are many answers to that question I guess.

1) assign a public IP to the container

2) redirect a single port to the container with iptables or a proxy


> - volumes to mount in LXC?

CONTAINER=some-container-name
MOUNTNAME=something
MOUNTPATH=/mnt/on/the/host
CONTAINERPATH=/mnt/inside/the/container
lxc config device add $CONTAINER $MOUNTNAME disk source=$MOUNTPATH 
path=$CONTAINERPATH


Tomasz Chmielewski
https://lxadm.com


More information about the lxc-users mailing list