So I'm building a rpm package with some pre-loaded docker image, and I want to load the image to the system and delete the image tar file after installation.
I've already achieved this in a debian package by simply adding these 2 lines in postinst
file:
docker load -i <path>/image.tar
rm <some_path>/image.tar
However I got some troubles doing this in RPM package and here's the .spec file roughly looks like:
%prep
%build
%install
mkdir -p %{buildroot}/etc/my_app/
cp app %{buildroot}/etc/my_app/app
cp image.tar %{buildroot}/etc/my_app/image.tar
%post
docker load -i /etc/my_app/image.tar
rm /etc/my_app/image.tar
%files
/etc/my_app/app
/etc/my_app/image.tar
%changelog
The first problem is that when installing the package, I got /bin/docker: Permission denied
error when running the %post scriptlets. (hence the image wasn't successfully loaded).
The second one is that when uninstalling the package, I got the warning: file /etc/edgexpert/image.tar: remove failed: No such file or directory
. I guess this is because I put the image.tar file under $file.
So my questions would be :
- how to make the
docker
command runnable? - where to put my
image.tar
file so that it can be used during %post scriptlets and won't be checked in %file
Thanks for the help.
Edited:
[vagrant@localhost ~]$ ls -l /bin/docker
-rwxr-xr-x. 1 root root 84956288 Jun 1 09:14 /bin/docker