saltstack / saltstack/salt

[BUG] intermediate docker image built through salt are not removed

Open
#65,122 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-triage
Dominant language
Python
Stars
15.7k
Forks
5.6k
Avg merge
2d 44m
Merged PRs (30d)
80

Description

Description
Shinken docker image built through salt is too big. Multiple intermediate images are built. Not possible to remove them as they are child of the parent image.

Setup
(Please provide relevant configs and/or SLS files (be sure to remove sensitive info. There is no general set-up of Salt.)

Please be as specific as possible and give set-up details.

  • on-prem machine
  • onedir packaging
shinken-image:
  docker_image.present:
    - build: {{ shinken_docker_dir }} # /root/shinken_docker
    - tag: latest
    - rm: true
    - require:
      - file: shinken_docker_repo    

Dockerfile in /root/shinken_docker

Steps to Reproduce the behavior
launch the state

Expected behavior
one docker image should be built. Instead multiple child images are built:

[root@admin1 ~]$ docker image ls -a
REPOSITORY      TAG       IMAGE ID       CREATED              SIZE
<none>          <none>    5b67bea55594   24 seconds ago       403MB
<none>          <none>    d6378c856fe7   24 seconds ago       403MB
shinken-image   latest    1eadd641561c   24 seconds ago       403MB
<none>          <none>    3781c8db14f1   24 seconds ago       403MB
<none>          <none>    a0356e967efd   24 seconds ago       403MB
<none>          <none>    b7ea644ccf0f   25 seconds ago       387MB
<none>          <none>    0df4d1ac3b91   25 seconds ago       387MB
<none>          <none>    5542746da436   27 seconds ago       387MB
<none>          <none>    730686e3aea3   27 seconds ago       387MB
<none>          <none>    0c4dcdd2a586   29 seconds ago       387MB
<none>          <none>    db83dda45979   About a minute ago   220MB
<none>          <none>    a722e5d56406   About a minute ago   204MB
<none>          <none>    d9d4cee3d4fc   About a minute ago   204MB
<none>          <none>    8bd8d68d7564   About a minute ago   220MB
<none>          <none>    ee943cd9d457   About a minute ago   204MB
centos          7         eeb6ee3f44bd   24 months ago        204MB

If doing the same from CLI:

[root@admin1 shinken_docker]$ docker build -t shinken-image:latest .

Only one image is built:

docker image ls -a
REPOSITORY      TAG       IMAGE ID       CREATED          SIZE
shinken-image   latest    ed60c3103723   11 seconds ago   403MB
centos          7         eeb6ee3f44bd   24 months ago    204MB
Salt Version:
          Salt: 3006.2

Python Version:
        Python: 3.10.12 (main, Aug  3 2023, 21:47:10) [GCC 11.2.0]

Dependency Versions:
          cffi: 1.14.6
      cherrypy: unknown
      dateutil: 2.8.1
     docker-py: 6.1.3
         gitdb: Not Installed
     gitpython: Not Installed
        Jinja2: 3.1.2
       libgit2: Not Installed
  looseversion: 1.0.2
      M2Crypto: Not Installed
          Mako: Not Installed
       msgpack: 1.0.2
  msgpack-pure: Not Installed
  mysql-python: Not Installed
     packaging: 22.0
     pycparser: 2.21
      pycrypto: Not Installed
  pycryptodome: 3.9.8
        pygit2: Not Installed
  python-gnupg: 0.4.8
        PyYAML: 6.0.1
         PyZMQ: 23.2.0
        relenv: 0.13.3
         smmap: Not Installed
       timelib: 0.2.4
       Tornado: 4.5.3
           ZMQ: 4.3.4

System Versions:
          dist: rocky 8.8 Green Obsidian
        locale: utf-8
       machine: x86_64
       release: 4.18.0-477.10.1.el8_8.x86_64
        system: Linux
       version: Rocky Linux 8.8 Green Obsidian

Additional context
Add any other context about the problem here.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Salt's docker_image.present handling of the build options and compare it with the CLI invocation described in the issue; no Salt source file or test is named. Done means a state using rm: true leaves only the tagged image, matching the docker build result.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, python
Domain
devops, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.