docker / for-linux

Docker Engine for Linux
https://docs.docker.com/engine/installation/
749 stars 85 forks source link

“restart_policy: condition: none” doesnt work as expected #316

Open senglert7 opened 6 years ago

senglert7 commented 6 years ago

Expected behavior

A Container with the following configuration should never restart after finishing:

tester:
    image: testimage
    deploy:
      restart_policy:
        condition: none
    command: sleep 10

This configuration I placed into a .yml-file and starting with 'docker stack deploy...'

Actual behavior

Container does not restart when his task is over, which is good. Container does restart when you restart the docker daemon, which is not expected.

Steps to reproduce the behavior

Start the above mentioned .yml config with 'docker stack deploy...'. Use any image instead of 'test'.

Output of docker version:

Containers: 19
 Running: 4
 Paused: 0
 Stopped: 15
Images: 141
Server Version: 1.13.1
Storage Driver: aufs
 Root Dir: /opt/disk2/docker/aufs
 Backing Filesystem: extfs
 Dirs: 178
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
Swarm: active
 NodeID: a64k7k1fqwlkx9itjeasyua68
 Is Manager: true
 ClusterID: ta5qg0fwpl0dpj3cj0wgeftlw
 Managers: 1
 Nodes: 5
 Orchestration:
  Task History Retention Limit: 5
 Raft:
  Snapshot Interval: 10000
  Number of Old Snapshots to Retain: 0
  Heartbeat Tick: 1
  Election Tick: 3
 Dispatcher:
  Heartbeat Period: 5 seconds
 CA Configuration:
  Expiry Duration: 3 months
 Node Address: 172.26.18.170
 Manager Addresses:
  172.26.18.170:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version:  (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1)
runc version: N/A (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f)
init version: N/A (expected: 949e6facb77383876aeff8a6944dde66b3089574)
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-87-generic
Operating System: Ubuntu 16.04.4 LTS
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 61.44 GiB
Name: test
ID: YHEF:JFD6:IUAR:U5S2:EQEO:4POK:5JSD:Z45O:DOZ3:SZSU:N7UL:GPNX
Docker Root Dir: /opt/disk2/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
WARNING: No swap limit support
Experimental: false
Insecure Registries:
 172.26.18.170:5000
 127.0.0.0/8
Live Restore Enabled: false

Output of docker info:

Client:
 Version:      1.13.1
 API version:  1.26
 Go version:   go1.6.2
 Git commit:   092cba3
 Built:        Thu Nov  2 20:40:23 2017
 OS/Arch:      linux/amd64

Server:
 Version:      1.13.1
 API version:  1.26 (minimum version 1.12)
 Go version:   go1.6.2
 Git commit:   092cba3
 Built:        Thu Nov  2 20:40:23 2017
 OS/Arch:      linux/amd64
 Experimental: false

Additional details With my application there is a service/container that should run only once. It initialized the database, which means even when the Docker host crashes and must be restarted, I dont want to run it again or else the Database gets reset.

clarsen commented 3 years ago

I still see this with:

Server: Docker Engine - Community
 Engine:
  Version:          20.10.6
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.13.15
  Git commit:       8728dd2
  Built:            Fri Apr  9 22:43:57 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.4
  GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8e
 runc:
  Version:          1.0.0-rc93
  GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdec
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0
hickst commented 2 years ago

This recent version (20.10.10) just reports that Error response from daemon: invalid restart policy 'none', in contradiction to the documentation.

Server: Docker Engine - Community
 Engine:
  Version:          20.10.10
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.16.9
  Git commit:       e2f740d
  Built:            Mon Oct 25 07:41:30 2021
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.4.11
  GitCommit:        5b46e404f6b9f661a205e28d59c982d3634148f8
 runc:
  Version:          1.0.2
  GitCommit:        v1.0.2-0-g52b36a2
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0