Using cp in start script on podman container

Hallo, I’m new podman user. the question is trivial one, but I have not find solution on google.
All that I find is post on DOCKER COPY, DOCKER CP or
cp from:

  • host to container or
  • container to host or
  • container to other container

    but I have to do a cp inside container after is runned:

from directory inside the container → to an existing directory inside the same container.

( … and is not a permission error)

my ContainerFile:

FROM fedora:latest

ENV LANG=C.UTF-8

#install some stuff
RUN dnf -y install findutils salt-master salt-api \
 && dnf clean all
#copy my bash start script
COPY entrypoint.sh /entrypoint.sh

#make a backup folder
RUN mkdir /etc/salt.dist

#backup some installathion data
RUN cp -a /etc/salt /etc/salt.dist

EXPOSE 4505/tcp 4506/tcp

#volume to mantein configuration, log, cache
VOLUME /etc/salt \
       /var/cache/salt \
       /var/log/salt \
       /srv

#start bash script when running
CMD ["/bin/bash","/entrypoint.sh"]

my build command: $ podman build -f Containerfile -t fedora/salt-master

the container build execute without error.

my entrypoint.sh file:

#!/bin/bash
set -o errexit
echo "I am root" && id
if [ -n "$( find "/etc/salt/" -maxdepth 0 -empty )" ]; then
	if [ -d "/etc/salt.dist/salt" ] && [ -r "/etc/salt.dist/salt" ]; then
    cp -a "/etc/salt.dist/salt/*" "/etc/salt/" 
   #^-- this above is not working
   # error: cp: cannot stat '/etc/salt.dist/salt/*': No such file or directory
	fi
fi
if [ -d "/etc/salt" ] && [ -r "/etc/salt" ]; then
  ls -la "/etc/salt"
fi

if I change
cp -a "/etc/salt.dist/salt/*" "/etc/salt/"
in
cp -a "/etc/salt.dist/salt" "/etc/salt/"

the cp commad run without error but
copy the dir salt on /etc/salt making /etc/salt/salt
and this is not what I want.

the problem have to be in /* and have to be easy to solve
but I am not be able to find a solution.

can anyone help?

best regards,
Leonardo

P.S.
my run command is this:
podman run -v ./volumes/etc/salt:/etc/salt:rw,z -v ./volumes/srv:/srv:rw,z -v ./volumes/var/cache/salt:/var/cache/salt:rw,z -v ./volumes/var/log/salt:/var/log/salt:rw,z --rm --name pod-master fedora/salt-master

Use can usually replace “docker” with “podman” , try podman cp.

Thank you gui.
I’m just using podman, and the directory copy have to be do, after container start, not at buildng time.
how can I use podman cp?
can you write an example?

best regards,
Leonardo

Aggiunto bash

I have solved the problem:
study this: layers

then change my Containerfile in:

FROM fedora:latest

#ENV LANG=en_US.UTF-8 LANGUAGE=en_US:en LC_ALL=en_US.UTF-8
ENV LANG=C.UTF-8
COPY entrypoint.sh /entrypoint.sh
EXPOSE 4505/tcp 4506/tcp
VOLUME /etc/salt \
       /etc/salt.dist \
       /var/cache/salt \
       /var/log/salt \
       /srv
RUN dnf -y install findutils salt-master salt-api \
 && dnf clean all \
 && cp -a /etc/salt /etc/salt.dist

CMD ["/bin/bash","/entrypoint.sh"]

and my entrypoint.sh in:

#!/bin/bash
set -o errexit
echo "I am root" && id
# se non viene montato il volume o e è vuoto copio la configurazione originale di salt salvata durante la build dell'immgine
if [ -n "$( find "/etc/salt/" -maxdepth 0 -empty )" ]; then
	if [ -d "/etc/salt.dist/salt" ] && [ -r "/etc/salt.dist/salt" ]; then
    cp -a /etc/salt.dist/salt/* /etc/salt/
	fi
fi
if [ -d "/etc/salt" ] && [ -r "/etc/salt" ]; then
  ls -la /etc/salt
fi

exec /usr/bin/salt-master

in Containerfile I have create a volume for /etc/salt.dist and put the RUN command at the last before the CMD command so /etc/sald.dist is visible in the final image layer

in entrypoint.sh I remove the " … so the
cp -a "/etc/salt.dist/salt/*" "/etc/salt/"
change in
cp -a /etc/salt.dist/salt/* /etc/salt/

now all work!

best regards Leonardo

P.S. my start command:
podman run -v ./volumes/etc/salt:/etc/salt:rw,z -v ./volumes/srv:/srv:rw,z -v ./volumes/var/cache/salt:/var/cache/salt:rw,z -v ./volumes/var/log/salt:/var/log/salt:rw,z --rm --name pod-master -it fedora/salt-master