Search code examples
dockersslnginxsystemd

How to correct invalid escape sequence in nginx unit file


I'm trying to mount a docker volume of the path my ssl certificate is being generated to. However when I add the path -v /etc/ssl:/etc/ssl \ into my nginx.service unit file:

[Service]
Restart=always
ExecStartPre=-/usr/bin/docker kill %p
ExecStartPre=-/usr/bin/docker rm -f %p
ExecStart=/usr/bin/docker run -t --rm --name %p \
  -p 80:80 -p 443:443 \
  --link custodian:custodian --volumes-from custodian \
  -v /etc/ssl:/etc/ssl \ 
  -v /etc/ssl/certs:/etc/ssl/certs \
  -v /var/www/letsencrypt/.well-known/acme-challenge:/var/www/letsencrypt/.well-known/acme-challenge \
  -v /etc/ssl/private:/etc/ssl/private %p
ExecStop=/usr/bin/docker stop %p

the nginx log returns:

[/etc/systemd/system/nginx.service:10] Invalid escape sequences in line, correcting: "/usr/bin/docker run -t --rm --name %p    -p 80:80 -p 443:443    --link custodian:custodian --volumes-from custodian    -v /etc/ssl:/etc/ssl \"

How can I adjust the unit file to mount correctly?


Solution

  • The problem is a trailing space in the line -v /etc/ssl:/etc/ssl \, after the \. This way it doesn't escape the line ending.