start systemd-nspawn/systemd container on boot

flooose

I've been working with systemd-nspawn and have a couple of containers that I'd like to automatically start at system start.

I'm using arch linux and according to the archwiki entry, the following code should do the trick

# systemctl enable [email protected]
# systemctl start [email protected]

Assuming the container MyContainer is in /var/lib/machines and was created with something like:

# pacstrap -i -c -d /var/lib/machines/MyContainer base

I can start the container with:

# sudo systemd-nspawn -b -D /var/lib/machines/MyContainer

and

# systemctl start [email protected]

as well as

# machinectl start MyContainer

but I just can't get the container to start at boot and running sudo systemctl status [email protected] right after boot doesn't show any errors. Does anyone know what I need to do? Does there maybe need to be another service running?

flooose

After doing a little more research, I discovered the problem. It's not that another service needs to be running, but instead another target, specifically machines.target, so running

systemctl enable machines.target

in addition to the commands above made it so that MyContainer starts at boot.

As a side note, this wasn't immediately clear because when I call

systemctl list-units --all --type=target

on both of my computers (both running arch linux), machines.target is not included in the list. Not sure why, but that was the fix.

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Systemd fails to start openvpn in lxd managed 16.04 container

분류에서Dev

Confused why systemd service doesn't start at boot

분류에서Dev

How do I make my systemd service run via specific user and start on boot?

분류에서Dev

start a service a at bootime in systemd

분류에서Dev

Normal boot (systemd) not working

분류에서Dev

SystemD Can't get script to start Samba4 Active Directory-Domain Controller (AD-DC) at boot Ubuntu 16.04

분류에서Dev

Systemd is unmounting my /boot partition

분류에서Dev

systemd: Failed to start Create System Users

분류에서Dev

Start / stop systemd automount on a single mountpoint

분류에서Dev

Start synergy on boot?

분류에서Dev

Systemd run daemon at boot like System V

분류에서Dev

start script at boot for kali linux

분류에서Dev

How to start a script file on boot?

분류에서Dev

iscsi won't start at boot

분류에서Dev

How to get systemd-udevd to create a bridge device at start up?

분류에서Dev

systemd-networkd fails to start when network booting via pxelinux

분류에서Dev

Start container instance on web request to FQDN

분류에서Dev

nfs boot hangs after systemd-networkd starts

분류에서Dev

systemd-boot 메뉴 표시 / 숨기기

분류에서Dev

Scripts in rc.local (start at boot), doesnot start

분류에서Dev

arch linux apache start at boot crash

분류에서Dev

How to start an application at boot time or as a service

분류에서Dev

Run 'sudo service mongod start' at boot time

분류에서Dev

systemd는 Docker Application Container Engine을 중지하지 않습니다.

분류에서Dev

openssh-server doesn't start in Docker container

분류에서Dev

Systemd: How to start/stop Python script that should run in background, inside Virtualenv

분류에서Dev

systemd-boot가 내 루트를 찾을 수 없습니다

분류에서Dev

systemd-boot : / vmlinuz-linux를 찾을 수 없음

분류에서Dev

systemd: user service starts at boot with target default/graphical but not multi-user

Related 관련 기사

  1. 1

    Systemd fails to start openvpn in lxd managed 16.04 container

  2. 2

    Confused why systemd service doesn't start at boot

  3. 3

    How do I make my systemd service run via specific user and start on boot?

  4. 4

    start a service a at bootime in systemd

  5. 5

    Normal boot (systemd) not working

  6. 6

    SystemD Can't get script to start Samba4 Active Directory-Domain Controller (AD-DC) at boot Ubuntu 16.04

  7. 7

    Systemd is unmounting my /boot partition

  8. 8

    systemd: Failed to start Create System Users

  9. 9

    Start / stop systemd automount on a single mountpoint

  10. 10

    Start synergy on boot?

  11. 11

    Systemd run daemon at boot like System V

  12. 12

    start script at boot for kali linux

  13. 13

    How to start a script file on boot?

  14. 14

    iscsi won't start at boot

  15. 15

    How to get systemd-udevd to create a bridge device at start up?

  16. 16

    systemd-networkd fails to start when network booting via pxelinux

  17. 17

    Start container instance on web request to FQDN

  18. 18

    nfs boot hangs after systemd-networkd starts

  19. 19

    systemd-boot 메뉴 표시 / 숨기기

  20. 20

    Scripts in rc.local (start at boot), doesnot start

  21. 21

    arch linux apache start at boot crash

  22. 22

    How to start an application at boot time or as a service

  23. 23

    Run 'sudo service mongod start' at boot time

  24. 24

    systemd는 Docker Application Container Engine을 중지하지 않습니다.

  25. 25

    openssh-server doesn't start in Docker container

  26. 26

    Systemd: How to start/stop Python script that should run in background, inside Virtualenv

  27. 27

    systemd-boot가 내 루트를 찾을 수 없습니다

  28. 28

    systemd-boot : / vmlinuz-linux를 찾을 수 없음

  29. 29

    systemd: user service starts at boot with target default/graphical but not multi-user

뜨겁다태그

보관