I have noticed this happening only in the case of failure.
For example, in python, if I try to install a package network manager and it fails due to some issue. Next time it will create a new container from an existing image.
Example:
balena push <ip-address>
[Info] Starting build on device <ip-address>
[Info] Creating default composition with source: .
[Build] [main] Step 1/8 : FROM balenalib/armv7hf-debian-python:3-stretch-run
[Build] [main] ---> <Tag>
[Build] [main] Step 2/8 : WORKDIR /usr/src/app
[Build] [main] Removing intermediate container 040129ef15a4
[Build] [main] ---> <Tag>
[Build] [main] Step 3/8 : COPY requirements.txt requirements.txt
[Build] [main] ---> <Tag>
[Build] [main] Step 4/8 : RUN pip install -r requirements.txt
[Build] [main] ---> Running in bb3db0ab3de8
[Build] [main] Collecting python-networkmanager (from -r requirements.txt (line 1))
[Build] [main] Downloading https://files.pythonhosted.org/packages/73/ec/2cc46290cedc99f59df3633d428dfa91d95946ca49af96fdb53514ee195f/python-networkmanager-2.1.tar.gz
[Build] [main] Collecting dbus-python (from python-networkmanager->-r requirements.txt (line 1))
[Build] [main] Downloading https://files.pythonhosted.org/packages/3f/e7/4edb582d1ffd5ac3c84188deea32e960b5c8c0fe1da56ce70224f85ce542/dbus-python-1.2.8.tar.gz (787kB)
[Build] [main] Collecting six (from python-networkmanager->-r requirements.txt (line 1))
[Build] [main] Downloading https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
[Build] [main] Installing collected packages: dbus-python, six, python-networkmanager
[Build] [main] Running setup.py install for dbus-python: started
[Build] [main] Running setup.py install for dbus-python: finished with status 'error'
[Build] [main] Complete output from command /usr/local/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-0pmhno41/dbus-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-2i7hweqi/install-record.txt --single-version-externally-managed --compile:
[Build] [main] running install
[Build] running build
[Build] creating /tmp/pip-install-0pmhno41/dbus-python/build
[Build] creating /tmp/pip-install-0pmhno41/dbus-python/build/temp.linux-armv7l-3.5
[Build] checking whether make supports nested variables... no
[Build] checking whether to enable maintainer-specific portions of Makefiles... no
[Build] checking for gcc... no
[Build] checking for cc... no
[Build] checking for cl.exe... no
[Build] configure: error: in `/tmp/pip-install-0pmhno41/dbus-python/build/temp.linux-armv7l-3.5':
[Build] configure: error: no acceptable C compiler found in $PATH
[Build] See `config.log' for more details
[Build] Traceback (most recent call last):
[Build] File "<string>", line 1, in <module>
[Build] File "/tmp/pip-install-0pmhno41/dbus-python/setup.py", line 109, in <module>
[Build] tests_require=['tap.py'],
[Build] File "/usr/local/lib/python3.5/site-packages/setuptools/__init__.py", line 143, in setup
[Build] return distutils.core.setup(**attrs)
[Build] File "/usr/local/lib/python3.5/distutils/core.py", line 148, in setup
[Build] dist.run_commands()
[Build] File "/usr/local/lib/python3.5/distutils/dist.py", line 955, in run_commands
[Build] self.run_command(cmd)
[Build] File "/usr/local/lib/python3.5/distutils/dist.py", line 974, in run_command
[Build] cmd_obj.run()
[Build] File "/usr/local/lib/python3.5/site-packages/setuptools/command/install.py", line 61, in run
[Build] return orig.install.run(self)
[Build] File "/usr/local/lib/python3.5/distutils/command/install.py", line 539, in run
[Build] self.run_command('build')
[Build] File "/usr/local/lib/python3.5/distutils/cmd.py", line 313, in run_command
[Build] self.distribution.run_command(command)
[Build] File "/usr/local/lib/python3.5/distutils/dist.py", line 974, in run_command
[Build] cmd_obj.run()
[Build] File "/tmp/pip-install-0pmhno41/dbus-python/setup.py", line 62, in run
[Build] cwd=builddir)
[Build] File "/usr/local/lib/python3.5/subprocess.py", line 271, in check_call
[Build] raise CalledProcessError(retcode, cmd)
[Build] subprocess.CalledProcessError: Command '['/tmp/pip-install-0pmhno41/dbus-python/configure', '--disable-maintainer-mode', 'PYTHON=/usr/local/bin/python3.5', '--prefix=/tmp/pip-install-0pmhno41/dbus-python/build/temp.linux-armv7l-3.5/prefix']' returned non-zero exit status 1
[Build]
[Build] ----------------------------------------
[Build] [main] Command "/usr/local/bin/python3.5 -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-0pmhno41/dbus-python/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-record-2i7hweqi/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-0pmhno41/dbus-python/
[Build]
[Build] [main] You are using pip version 19.0.1, however version 19.1.1 is available.
[Build] You should consider upgrading via the 'pip install --upgrade pip' command.
[Build]
Some services failed to build:
main: The command '/bin/sh -c pip install -r requirements.txt' returned a non-zero code: 1
Additional information may be available by setting a DEBUG=1 environment
variable: "set DEBUG=1" on a Windows command prompt, or "export DEBUG=1"
on Linux or macOS.
If you need help, don't hesitate in contacting our support forums at
https://forums.balena.io
For bug reports or feature requests, have a look at the GitHub issues or
create a new one at: https://github.com/balena-io/balena-cli/issues/
Now I’ll make some changes and try to install it again:
9318fd0d0f68 83ad743c2d48 "/bin/sh -c 'apt-get…" 15 seconds ago Up 5 seconds frosty_saha
bb3db0ab3de8 83ad743c2d48 "/bin/sh -c 'pip ins…" 8 minutes ago Exited (1) 4 minutes ago angry_poitras
As you can see it’s using the same image But created a new container.
Thus it consumes the space on the device. Is there any way I can push on same container?