Select Your Language

Infrastructure and Management

Cloud Computing

Storage

Runtimes

Integration and Automation

  • Comments
  • Can't Start Container as a Service for a user

    Posted on

    Hi Community,

    I created an Nginx container name "website. I want to start it as a service for the "hatred" user.

    bb58924e9431  docker.io/library/nginx:latest  nginx -g daemon o...  47 hours ago  Up 2 seconds ago  0.0.0.0:8080->80/tcp  website
    

    I created directories in the user's home directory and user "hatred" is the owner of the directories.

    /home/hatred/.config/systemd/user
    

    Then I generated the service by using container id, I tried the name as well. Here is the command I used and got the below result.

    #podman generate systemd --name bb58924e9431 --files --new
    /home/hatred/.config/systemd/user/container-website.service
    

    I verified the file got generated

    [root@hatred user]# ls -l
    total 4
    -rw-r--r--. 1 root root 770 Jul 26 20:56 container-website.service
    

    Then I reloaded the daemon

    .# systemctl --user daemon-reload 
    

    However when I try to start or enable the service I get "Failed to start container-website.service: Unit container-website.service not found. " or "Failed to enable unit: Unit file container-website.service does not exist." error.

    #systemctl --user start container-website.service
    Failed to start container-website.service: Unit container-website.service not found.
    
    systemctl --user enable container-website.service
    Failed to enable unit: Unit file container-website.service does not exist.
    

    Here are the "container-website.service" file's contents.

    # container-website.service
    # autogenerated by Podman 4.0.2
    # Tue Jul 26 20:56:59 MST 2022
    
    [Unit]
    Description=Podman container-website.service
    Documentation=man:podman-generate-systemd(1)
    Wants=network-online.target
    After=network-online.target
    RequiresMountsFor=%t/containers
    
    [Service]
    Environment=PODMAN_SYSTEMD_UNIT=%n
    Restart=on-failure
    TimeoutStopSec=70
    ExecStartPre=/bin/rm -f %t/%n.ctr-id
    ExecStart=/usr/bin/podman run --cidfile=%t/%n.ctr-id --cgroups=no-conmon --rm --sdnotify=conmon --replace --name website -v /web:/usr/share/nginx/html:Z -d -p 8080:80 nginx:latest
    ExecStop=/usr/bin/podman stop --ignore --cidfile=%t/%n.ctr-id
    ExecStopPost=/usr/bin/podman rm -f --ignore --cidfile=%t/%n.ctr-id
    Type=notify
    NotifyAccess=all
    
    [Install]
    WantedBy=default.target
    

    I created a service for the root and added it to the system directory, I was able to start that service as root, but the user's service is not getting started. Any idea how can I fix this issue?
    Thank you for your help.

    by

    points

    Responses

    Red Hat LinkedIn YouTube Facebook X, formerly Twitter

    Quick Links

    Help

    Site Info

    Related Sites

    © 2025 Red Hat