I have a system down for maintenance, and I want to start dockerd such that I can execute docker commands, but I don't want its existing containers to auto-start. This is very useful, for instance, in a maintenance mode or system upgrade situation. I cannot find an option to handle this.

1 Answer 1


Not a real answer, but a work-around:

Show containers's RestartPolicy:

find /var/lib/docker/containers/ -type f -name hostconfig.json \
-exec grep -o '"RestartPolicy[^}]*}'  {} +

To change these policies to 'never', I used the following script:

find /var/lib/docker/containers/ -type f -name hostconfig.json \
-exec grep -o '"RestartPolicy[^}]*}'  {} + |
  grep -v '"never"'  |
  cut -d: -f1
  xargs -r \
    sed  -i 's/\("RestartPolicy":{"Name":\)"[^"]*"/\1"no"/'

Then you can start docker, and all the containers will be disabled. However, resetting the auto-start settings must be done manually.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .