Tag: systemctl

  • How To Use Systemctl to Manage Systemd Services and Units

    All credits to:

    jellingwood @ Digitalocean.com

     Introduction

    Systemd is an init system and system manager that is widely becoming the new standard for Linux machines. While there are considerable opinions about whether systemd is an improvement over the traditional SysV init systems it is replacing, the majority of distributions plan to adopt it or have already done so.

    Due to its heavy adoption, familiarizing yourself with systemd is well worth the trouble, as it will make administrating these servers considerably easier. Learning about and utilizing the tools and daemons that comprise systemd will help you better appreciate the power, flexibility, and capabilities it provides, or at least help you to do your job with minimal hassle.

    In this guide, we will be discussing the systemctl command, which is the central management tool for controlling the init system. We will cover how to manage services, check statuses, change system states, and work with the configuration files.

  • Docker autostart container

    Docker autostart container

    Create service

    make file in /etc/systemd/system/

    cd /etc/systemd/system
    nano /docker-[containername].service

    Insert following code:

    [Unit]
    Description=Docker [containername] server
    Requires=docker.service
    After=docker.service
    [Service]
    Restart=always
    ExecStart=/usr/bin/docker start -a [containername]
    ExecStop=/usr/bin/docker stop -t 2 [containername]
    [Install]
    WantedBy=default.target

    Add service to systemd

    systemctl enable docker-[containername].service

    When system reboots, service will be started.