Skip to content

docker image prune/rm removes in-use image tags #36295

@githubsaturn

Description

@githubsaturn

BUG REPORT INFORMATION

Describe the results you received:
Running docker image prune --all --force removes IN-USE images causing locally created images to get lost.

Describe the results you expected:
If a service is running via locally-create-image:1, running docker image prune --all --force SHOULD NOT remove locally-create-image:1

Steps to reproduce the issue:

  1. docker swarm init # simply create a swarm
  2. mkdir /test-bug
  3. cd /test-bug
  4. echo "FROM nginx:1.13.8" > Dockerfile # this is an example, it can be anything
  5. docker build -t myimage:1 .
  6. docker service create --name my-service myimage:1
  7. wait and make sure that your container is running. Check using docker ps -a, you will see image is listed as myimage:1
  8. docker image prune --all --force # this is supposed to remove all "unused" images
  9. docker service update my-service --force # this can be an update of environmental variables or anything else that causes a container restart.
  10. You will see that the service does not get restarted as there is no myimage:1 image!

Additional information you deem important (e.g. issue happens only occasionally):

Output of docker version:

Client:
 Version:	17.12.0-ce
 API version:	1.35
 Go version:	go1.9.2
 Git commit:	c97c6d6
 Built:	Wed Dec 27 20:11:19 2017
 OS/Arch:	linux/amd64

Server:
 Engine:
  Version:	17.12.0-ce
  API version:	1.35 (minimum version 1.12)
  Go version:	go1.9.2
  Git commit:	c97c6d6
  Built:	Wed Dec 27 20:09:53 2017
  OS/Arch:	linux/amd64
  Experimental:	false

Output of docker info:

Containers: 7
 Running: 4
 Paused: 0
 Stopped: 3
Images: 66
Server Version: 17.12.0-ce
Storage Driver: aufs
 Root Dir: /var/lib/docker/aufs
 Backing Filesystem: extfs
 Dirs: 113
 Dirperm1 Supported: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: active
 NodeID: hl08z3yjk34msargicyuklvzy
 Is Manager: true
 ClusterID: k883g1werpi8dj207nr09kj3h
 Managers: 1
 Nodes: 1
 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
  Force Rotate: 0
 Autolock Managers: false
 Root Rotation In Progress: false
 Node Address: 174.7.187.204
 Manager Addresses:
  174.7.187.204:2377
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 89623f28b87a6004d4b785663257362d1658a729
runc version: b2567b37d7b75eb4cf325b77297b140ea686ce8f
init version: 949e6fa
Security Options:
 apparmor
 seccomp
  Profile: default
Kernel Version: 4.4.0-112-generic
Operating System: Ubuntu 16.04.3 LTS
OSType: linux
Architecture: x86_64
CPUs: 8
Total Memory: 7.682GiB
Name: REMOVED
ID: REMOVED
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Username: dockersaturn
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

WARNING: No swap limit support

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions