Welcome to the Linux Foundation Forum!

Lab 3.3 - systemd-nspawn - login to container


Lab 3.3 goes through the process of debootstrapping a container and booting it. However, the explanations stop short at how to actually login and use that container.

Searching the WWW I found the answer. Before running systemd-nspawn -bD ~/DebianContainer/, run the following:

root@ubuntu:~# systemd-nspawn -D ~/DebianContainer/
Spawning container DebianContainer on /root/DebianContainer.
Press ^] three times within 1s to kill container.
Host and machine ids are equal (a006ae0037b045dd8276dd6252395133): refusing to link journals
root@DebianContainer:~# passwd
New password: 
Retype new password: 
passwd: password updated successfully
root@DebianContainer:~# exit
Container DebianContainer exited successfully.
root@ubuntu:~# systemd-nspawn -b -D ~/DebianContainer/

It's very simple, but without it the entire exercise is like travelling to Ghiza (Egypt) and not seeing the pyramids.


  • chrispokorni
    chrispokorni Posts: 2,190

    Hi @heiko_s,

    Thanks for your feedback. This is an elegant method indeed.
    You can also hack your way into the container by editing root entry in the /root/DebianContainer/etc/passwd file.


  • heiko_s
    heiko_s Posts: 99

    Thanks Chris!


Upcoming Training