Score:0

How to run docker container as service if docker installed using snap

jp flag

I have faced with the issue that when I create the following service:

Description=Start Service Code
After=snap.docker.dockerd.service
Wants=network-online.target
Requires=snap.docker.dockerd.service

[Service]
Restart=always
ExecStart=/snap/bin/docker run -dt --rm --privileged --shm-size=0 --group-add root -p 8080:8080/tcp -p 8081:8081/tcp -v /dev:/dev service/tag
ExecStop=/snap/bin/docker stop $(/snap/bin/docker ps | grep "service/tag" | cut -d " " -f 1)

[Install]
WantedBy=default.target

Service is not started and during start it produce few issues:

systemd[1]: myservice.service: Converting job myservice.service/restart -> myservice.
systemd[1]: myservice.service: Failed to set 'blkio.weight' attribute on '/system.slice/myservice.service' to '500': No such file 
systemd[1]: myservice.service: Passing 0 fds 
systemd[1]: myservice.service: About to execute: /snap/bin/docker run -dt --rm --privileged --shm-size=0 --group-add root -p 8080:8080/tcp -
systemd[1]: myservice.service: Forked /snap/bin/docker 
systemd[1]: myservice.service: Changed dead 
systemd[1]: myservice.service: Job 14944 myservice.service/start finished, 
systemd[1]: Started Start 
systemd[249465]: myservice.service: Executing: /snap/bin/docker run -dt --rm --privileged --shm-size=0 --group-add root -p 8080:8080/tcp -
systemd[1]: myservice.service: Control group is empty.

Have somebody faced with the same issue ?

Artur Meinild avatar
vn flag
Why do you need to run a container as a service?
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.