"lxc launch" an already existing CT name by mistake

Sorry for the trivial question, but I have to ask if only for reassurance (since I couldn’t find the answer in the docs): What happens if I accidentally try to lxc launch an already existing (and running) CT name?

I canceled the launch immediately with Ctrl-Cs, but it didn’t output any error messages (e.g. “CT with name ‘myct’ already exists, exiting …”)

myname@mylxdhost:~$ lxc launch images:debian/11 myct
Creating myct
Error: User signaled us three times, exiting. The remote operation will keep running
myname@mylxdhost:~$ ^C
myname@mylxdhost:~$ ^C

root@mylxdhost:~# tail /var/log/lxd/lxd.log
t=2022-01-31T16:14:32+0100 lvl=info msg="Pruning expired images" 
t=2022-01-31T16:14:32+0100 lvl=info msg="Done pruning expired images" 
t=2022-01-31T16:16:37+0100 lvl=info msg="Updating images" 
t=2022-01-31T16:16:37+0100 lvl=info msg="Done updating images" 
t=2022-01-31T22:16:37+0100 lvl=info msg="Updating images" 
t=2022-01-31T22:16:37+0100 lvl=info msg="Done updating images" 
t=2022-02-01T01:22:41+0100 lvl=warn msg="Detected poll(POLLNVAL) event." 
t=2022-02-01T01:22:46+0100 lvl=warn msg="Detected poll(POLLNVAL) event." 
t=2022-02-01T03:57:20+0100 lvl=info msg="Downloading image" alias=debian/11 image=866c279796ba543b5a37a7483
d405bfe66633cf69250d1d3fbbab442f01017e9 operation=70110760-d700-4ab3-8993-dd6ef1d70118 server=https://image
s.linuxcontainers.org trigger=/1.0/operations/70110760-d700-4ab3-8993-dd6ef1d70118
t=2022-02-01T03:58:23+0100 lvl=info msg="Image downloaded" alias=debian/11 image=866c279796ba543b5a37a7483d
405bfe66633cf69250d1d3fbbab442f01017e9 operation=70110760-d700-4ab3-8993-dd6ef1d70118 server=https://images
.linuxcontainers.org trigger=/1.0/operations/70110760-d700-4ab3-8993-dd6ef1d70118

Thank you in advance, KP

I mean instead of:

Creating myct

I would have expected an error message like:

Error: CT with name ‘myct’ already exists, use --force if you want to re-initialize container, exiting …

or something to that effect …

stgraber@dakara:~$ lxc launch images:alpine/edge a1
Creating a1
Error: Failed instance creation: Failed creating instance record: Add instance info to the database: This "instances" entry already exists

So it would have told you that eventually, but first it was dealing with the image you requested, causing it to resolve the image and refresh the cache from the remote image, once that would have completed, it would have gone to actually process the instance request and fail with an error like this one.

1 Like

Thank you for clearing this up. The last message “… operation will keep running” was quite alarming to me.

Perhaps in this case the error messages could have been more clear (and also recorded in the log that the operation was in fact aborted).

I guess some of us only use LXD/LXC occasionally (for permanent containers instead of VMs) and aren’t used to its quirks :wink: