图像未拉入 systemd ExecStartPre=

Image not pulled in systemd ExecStartPre=

我从 systemd/dockerd 收到这条消息:

Dec 29 14:41:32 core-01 systemd[1]: Starting ElasticSearch...
Dec 29 14:41:32 core-01 docker[1335]: Error response from daemon: No such container: es
Dec 29 14:41:32 core-01 docker[1346]: Error response from daemon: No such container: es
Dec 29 14:41:33 core-01 docker[1367]: Pulling repository prv.private.registry/elasticsearch-qa
Dec 29 14:41:33 core-01 docker[1367]: Error: image elasticsearch-qa not found
Dec 29 14:41:33 core-01 systemd[1]: living-es.service: Control process exited, code=exited status=1

所以它告诉我 image elasticsearch-qa not found

systemd 服务定义为:

  - name: living-es.service
    command: start
    enable: true
    content: |-
      [Unit]
      Description=ElasticSearch
      Author=Living
      After=docker.service

      [Service]
      Restart=always
      RestartSec=10s
      ExecStartPre=-/usr/bin/docker stop es
      ExecStartPre=-/usr/bin/docker rm es
      ExecStartPre=/usr/bin/docker pull prv.private.registry/elasticsearch-qa:v1
      ExecStart=/usr/bin/docker run --name es -p 9200:9200 -p 9300:9300 --hostname es -v /home/core/data/es:/usr/share/elasticsearch/data prv.private.registry.com/elasticsearch-qa:v1 -Des.node.name="esn1" -Des.cluster.name="cluster"
      ExecStop=/usr/bin/docker stop es

消息很清楚,但是,当我在 shell 上拉取图像时,它被正确拉取了。有什么想法吗?

docker pull prv.private.registry/elasticsearch-qa:v1
v1: Pulling from elasticsearch-qa
8ad8b3f87b37: Pull complete
751fe39c4d34: Pull complete
b165e84cccc1: Pull complete
acfcc7cbc59b: Pull complete
04b7a9efc4af: Pull complete
b16e55fe5285: Pull complete
8c5cbb866b55: Pull complete
53c3dd7fc70d: Pull complete
3de13756a8c8: Pull complete
64be422416b7: Pull complete
b808918635ce: Pull complete
5b3ceec8c156: Pull complete
561269d0b7cc: Pull complete
0c6cf9533753: Pull complete
5234b57e3d12: Pull complete
4a86b042378a: Pull complete
c6f98581a18c: Pull complete
b6ee1115f29d: Pull complete
Digest: sha256:1f3c29d4f10ae897f67067ff72b8e25d8380531f04637941e67747bec96228f9code=exited status=1
Status: Downloaded newer image for prv.private.registry/elasticsearch-qa:v1

尝试 运行 以 root 的身份手动执行 docker pull 命令,因为那是 systemd 运行 的用户。它可能无法验证您的私人存储库,因为凭据存储在您的用户首选项中。

如果是这样,请尝试将 User=yourusername 添加到您的 systemd 单元文件中。