0

I tried to create a systemd script for a docker service:

[Unit]
Description=ScyllaDB 1
After=network-online.target docker.target
Wants=network-online.target systemd-networkd-wait-online.service docker.target

[Service]
Type=notify
Restart=on-failure
RestartSec=10s

User=foo
Group=users

WorkingDirectory=/home/foo/scylladb

ExecStartPre=/usr/bin/docker pull scylladb/scylla
ExecStart=/usr/bin/docker run --volume /home/foo/scylla1:/var/lib/scylla --name scylla1 \
    scylladb/scylla --developer-mode 1 --memory 1.5G --smp 3 \
    --listen-address 127.0.0.1 
    # --overprovisioned 1 --seeds 127.0.0.1 --broadcast-address 127.0.1.1
ExecStop=/usr/bin/docker stop scylla1

LimitNOFILE=1048576

ProtectSystem=full
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target

I've done executing:

sudo usermod -aG docker foo
mkdir -p /home/foo/scylla1/commitlog /home/foo/scylla1/data
sudo chown foo:users /home/foo/scylla1
sudo systemctl daemon-reload

EDIT: When I tried to run the command manually using foo user it works fine, but when using sudo systemctl restart scylladb it shows an error:

May 17 14:58:55 x systemd[1]: Stopped ScyllaDB 1.
May 17 14:58:55 x systemd[1]: Starting ScyllaDB 1...
May 17 14:58:55 x systemd[1]: scylladb.service: Control process exited, code=exited status=210
May 17 14:58:55 x systemd[1]: Failed to start ScyllaDB 1.
May 17 14:58:55 x systemd[1]: scylladb.service: Unit entered failed state.
May 17 14:58:55 x systemd[1]: scylladb.service: Failed with result 'exit-code'.

Manually:

[foo@x ~]$ /usr/bin/docker pull scylladb/scylla
Using default tag: latest
latest: Pulling from scylladb/scylla
93857f76ae30: Already exists 
fcf3425de92f: Already exists 
a9768670d266: Already exists 
eaccce6402ed: Already exists 
a564f24ba7ea: Already exists 
c1c511852d0b: Already exists 
f9c8010402b4: Already exists 
654f38ed538a: Already exists 
64856b4587d3: Already exists 
74fbc1822a2d: Already exists 
fdeb9fe209e1: Already exists 
243856d4fcb5: Already exists 
0b59d050d95e: Already exists 
e677bcc6c3d3: Already exists 
ca2f175eb91a: Already exists 
912e754404b4: Already exists 
c80ea560f85c: Already exists 
9f2fa2f93fae: Already exists 
04cfbbeb59e2: Already exists 
a9996b00766d: Already exists 
1076dbbc8e7b: Already exists 
c4eda4b22480: Already exists 
Digest: sha256:9c9d23b9ab9bd392cf647d861edc1f48498f6c7ffd142ab9905c23cc3c463345
Status: Image is up to date for scylladb/scylla:latest
[foo@x ~]$ /usr/bin/docker pull scylladb/scylla^C
[foo@x ~]$ /usr/bin/docker run --volume /home/foo/scylla1:/var/lib/scylla --name scylla1 \
>         -d scylladb/scylla --developer-mode 1 --memory 1.5G --smp 3 \
>         --listen-address 127.0.0.1 
4c6e7685e5297028e582e7c19c75424dbf3160a0e46adb69325993d333dbae7e
[foo@x ~]$ /usr/bin/docker stop scylla1
scylla1

What's the possible cause for this?

4
  • Have you relogged in as foo? Does the output of groups for user foo include the group docker? (I don't think that's the problem though) More pertinently, is the system running SELinux? Commented May 17, 2017 at 7:32
  • yes, the user foo includes docker, no i don't use selinux.. Commented May 17, 2017 at 7:37
  • btw it works now, so i edit the question now Commented May 17, 2017 at 8:01
  • 1
    Hmm, that seems like a problem with the service - I'm guessing something with authentication/permission. What is the output of journalctl -u scylladb.service? Also, shouldn't the Group directive under Service be "docker" and not "users"?? Commented May 17, 2017 at 8:27

1 Answer 1

0

Apparently the problem is because the working directory doesn't exists, it should be /home/foo/scylla1 not /home/foo/scylladb, the second part of the problem is 1.5G is not valid parameter, 1G or 2G works fine.

Here's the final systemd scylladb.service file:

[Unit]
Description=ScyllaDB 1
After=network-online.target docker.target
Wants=network-online.target systemd-networkd-wait-online.service docker.target

[Service]
Type=simple
Restart=on-failure
RestartSec=10s

User=foo
Group=docker

WorkingDirectory=/home/foo/scylla1
ExecStartPre=/usr/bin/docker rm scylla1
ExecStart=/usr/bin/docker run --volume /home/foo/scylla1:/var/lib/scylla --name scylla1 scylladb/scylla --developer-mode 1 --memory 2G --smp 3 --listen-address 127.0.0.1 
    # --overprovisioned 1 --seeds 127.0.0.1 --broadcast-address 127.0.1.1
ExecStop=/usr/bin/docker stop scylla1

LimitNOFILE=1048576

ProtectSystem=full
NoNewPrivileges=true

[Install]
WantedBy=multi-user.target

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.