Skip to content

service --log-opt only works if you also specify --log-driver #8745

Closed

Description

@Tomcat-Engineering

Problem description

If you run docker service update myservice --log-opt mode=blocking then it appears to run successfully but doesn't actually do anything. In order to get it to set the log options, you also have to include the --log-driver flag in the same command.

This is mentioned in passing here

One day it would be nice if the command did actually honour the settings, but for now it would be helpful if the documentation mentioned the issue.

Problem location

https://docs.docker.com/engine/reference/commandline/service_create/ and https://docs.docker.com/engine/reference/commandline/service_update/

Suggestions for a fix

Add a comment in the documentation so that people don't spend ages wondering why their options aren't being applied.

Activity

  1. paigehargrave commented on Jun 1, 2019

    @paigehargrave
    Contributor

    @thaJeztah Not sure if there's still an issue here (per moby/moby#31515 (comment)) - can you PTAL when you have a free moment (har har). Thanks!

  2. thaJeztah commented on Jun 12, 2019

    @thaJeztah
    Member

    Thanks @Tomcat-Engineering (and thanks for the ping @paigehargrave)

    Hm.. alright; so this looks to be a combination of something that's by design, and (what I think is) a bug in the docker service update logic; docker service create and update should follow slightly different logic (and I think they currently use the same).

    • expected: setting log-opt for a service that does not have a logging-driver configured isn't supported
    • t.b.d.: creating a service with a log-opt set, but no logging driver silently ignores the option
      • should it produce an error? a warning?
    • bug: setting log-opt for a service that has a logging driver configured (when created), but without specifying that driver during update is silently ignored.
      • when updating a service, the CLI should take the existing logging-driver, and update the options

    Taking a full example;

    docker service create --log-driver=json-file --log-opt max-file=5 --name loggie nginx:alpine
    docker service inspect --format='{{json .Spec.TaskTemplate.LogDriver}}' loggie
    {"Name":"json-file","Options":{"max-file":"5"}}

    Updating without logging-driver set doesn't take effect. IMO this should work, given that the service already had a logging-driver configured. It should still fail (or warn) if no logging-driver was configured yet on the service.

    docker service update --log-opt max-file=15 loggie
    docker service inspect --format='{{json .Spec.TaskTemplate.LogDriver}}' loggie
    {"Name":"json-file","Options":{"max-file":"5"}}

    Updating with a logging driver specified does;

    docker service update --log-driver=json-file --log-opt max-file=15 loggie
    docker service inspect --format='{{json .Spec.TaskTemplate.LogDriver}}' loggie
    {"Name":"json-file","Options":{"max-file":"15"}}

    So, I agree that we should document this (or at least make sure that any example we have does use the right combination). This bug doesn't look critical (and there's a workaround), so likely won't find its way back in all older releases (e.g. likely won't be fixed in Docker Enterprise 17.06), so having this documented would be useful even if it might be fixed in a future update.

    I'll copy the information here to the docker/cli issue tracker (where I think the bug is), and will post a link to that issue here.

  3. thaJeztah commented on Jun 12, 2019

    @thaJeztah
    Member
  4. docker-robott commented on Nov 30, 2022

    @docker-robott
    Collaborator

    There hasn't been any activity on this issue for a long time.
    If the problem is still relevant, mark the issue as fresh with a /remove-lifecycle stale comment.
    If not, this issue will be closed in 14 days. This helps our maintainers focus on the active issues.

    Prevent issues from auto-closing with a /lifecycle frozen comment.

    /lifecycle stale

  5. docker-robott commented on Jan 13, 2023

    @docker-robott
    Collaborator

    Closed issues are locked after 30 days of inactivity.
    This helps our team focus on active issues.

    If you have found a problem that seems similar to this, please open a new issue.

    /lifecycle locked

  6. locked and limited conversation to collaborators on Jan 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions