packer lxc failing to create container
Dialgatrainer02 opened this issue Β· comments
Community Note
- Please vote on this issue by adding a π reaction to the original issue to help the community and maintainers prioritize this request
- Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
- If you are interested in working on this issue or have submitted a pull request, please leave a comment
When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.
Overview of the Issue
when i run packer build . i get errors saying it couldnt create the vm
and im unsure why i can create containers using
sudo lxc-create -t download -n packer-test -- -d alpine -a amd64
Reproduction Steps
install lxc
git clone https://github.com/jpancoast/image-builder.git
cd ./image-builder/lxc/examples/alpine
sudo packer init .
sudo chmod +x build.sh
sudo bash build.sh
Packer version
From packer version
Packer v1.10.2-dev
Your version of Packer is out of date! The latest version
is 1.10.2. You can update by downloading from www.packer.io/downloads
Simplified Packer Template
If the file is longer than a few dozen lines, please include the URL to the
gist of the log or use the Github detailed
format
instead of posting it directly in the issue.
git clone https://github.com/jpancoast/image-builder.git this is my first time using packer so just coping a git repo
Operating system and Environment details
OS, Architecture, and any other information you can provide about the
environment.
arch linux (just for testing)
x86_64
packer and lxc on latest versions
Log Fragments and crash.log files
Include appropriate log fragments. If the log is longer than a few dozen lines,
please include the URL to the gist of the log or
use the Github detailed format instead of posting it directly in the issue.
https://gist.github.com/Dialgatrainer02/c28b16d8a7ab72424323b91e3294d38e
Set the env var PACKER_LOG=1
for maximum log detail.
Hi @Dialgatrainer02,
With the information provided it's a bit hard for us to understand what the bug is, or if this is even a Packer or a LXC plugin issue that we can act on.
To be sure, are you able to manually create a LXC container with the image you're building upon? That would be a first starting point in order to rule out problems like an unavailable image or a permission problem.
Please note that I'm very much not a LXC expert, so please bear with me on that one. I see the template you're using refers to a configuration file located in /etc/lxc/default.conf
, have you created the template in this location? That might very well be the problem here if not.
Thanks in advance for elaborating on this problem!
my /etc/lxc/default.conf is
lxc.net.0.type = veth
lxc.net.0.link = lxcbr0
lxc.net.0.flags = up
lxc.net.0.hwaddr = 00:16:3e:xx:xx:xx
i am trying to make an alpine image and i can successfully make it using the command: sudo lxc-create -t download -n packer-lxc -- -d alpine -a amd64
and selecting 3.19
i just tried to do lxc start on the container using: sudo lxc-start packer-lxc and it gave an error
lxc-start: packer-lxc: ../src/lxc/lxccontainer.c: wait_on_daemonized_start: 837 Received container state "ABORTING" instead of "RUNNING"
lxc-start: packer-lxc: ../src/lxc/tools/lxc_start.c: lxc_start_main: 307 The container failed to start
lxc-start: packer-lxc: ../src/lxc/tools/lxc_start.c: lxc_start_main: 310 To get more details, run the container in foreground mode
lxc-start: packer-lxc: ../src/lxc/tools/lxc_start.c: lxc_start_main: 312 Additional information can be obtained by setting the --logfile and --logpriority options
running with -F gives me
lxc-start: packer-lxc: ../src/lxc/network.c: netdev_configure_server_veth: 735 No such file or directory - Failed to attach "vethqKJUfy" to bridge "lxcbr0", bridge interface doesn't exist
lxc-start: packer-lxc: ../src/lxc/network.c: lxc_create_network_priv: 3463 No such file or directory - Failed to create network device
lxc-start: packer-lxc: ../src/lxc/start.c: lxc_spawn: 1847 Failed to create the network
lxc-start: packer-lxc: ../src/lxc/start.c: __lxc_start: 2114 Failed to spawn container "packer-lxc"
lxc-start: packer-lxc: ../src/lxc/tools/lxc_start.c: lxc_start_main: 307 The container failed to start
lxc-start: packer-lxc: ../src/lxc/tools/lxc_start.c: lxc_start_main: 312 Additional information can be obtained by setting the --logfile and --logpriority options
it seems to be having networking issues
ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
4: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DORMANT group default qlen 1000
link/ether f8:e4:e3:8d:56:8f brd ff:ff:ff:ff:ff:ff
Thanks for the quick confirmation.
The sudo
part worries me, were you running packer
as superuser as well? This could be a permission problem.
Docker has the same kind of problem as you need to add yourself to a group in order for the daemon to spawn a container, otherwise you get a permission error.
I would also suggest taking a look at the options offered by the builder in order to get more troubleshooting information, typically as pointed out by LXC here through the --logfile
option. I believe you can set it with the start_options
argument for the source.
i am running packer build and init with sudo and ill look into getting a logfile
Regarding your bridge interface not existing, there's an issue on LXC that hints at the potential problem, I suggest taking a look at the (former) maintainer's suggestion: lxc/lxc#1218 (comment)
This issue has been migrated to hashicorp/packer-plugin-lxc#76 due to the Packer Plugin split.
Please follow the new issue for updates.
On another note, since this is a LXC-specific bug, I'm transferring the issue to the plugin for further discussion.
okay thanks for the help
I'm going to lock this issue because it has been closed for 30 days β³. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.