Well I wish to copy files from the host to a docker container. Many solutions give the command
docker cp ...
However this doesn't work in my case. In my case the one initializing the command is the docker itself. The initial startup triggers a special script in the docker that will copy all files, and initializes the docker. (normally from a git repo, but for debugging I wish to enable copy from file system).
The problem is, inside the docker the docker command doesn't exist. So I can't use docker cp. So how to do this? Just so I can speed up development (instead of having to push each minor update during testing I could then test directly).
For clearing up things, my docker image has as entry point
init.sh
This file is hence called each startup, it contains (amongst other setup properties the following:
if [ ! -f /initialized ]; then
apk add --virtual .init-deps bash
if [ -z ${FILE} ]; then
echo "Building from server"
apk add --virtual .init-deps git
bash load_git.sh "${GIT_SERVER}" "${GIT_USERNAME}" "${GIT_PASSWORD}"
echo clone done
else
echo "Building from file"
bash load_filestystem.sh "${FILE}"
echo copying done
fi
if [ $? -eq 0]; then
sh copy_code.sh
if [ $? -eq 0 ]; then
echo "Build success"
touch /initialized
fi
fi
apk --purge del .init-deps
fi
load_git.sh contains the following line:
git clone https://${USERNAME}:${PASSWORD}@${REPOSITORY} tmp
It clones the git repository and puts it in the temporary folder "to be copied". Now I wish to make load_filesystem.sh do the "same" except from an external repository I wish it to "clone" from the host system.
This to allow tests & working to continue while the external repository is not available.
Notice that init.sh is run from within the container (it's the entrypoint).
Before people ask: we choose this setup, instead of docker build files since synology NAS servers seems to wish to be served an image file directly. To improve deployment speed we then make images that are generic, and load the code upon first run (or restart with a flag).
So in the end the question is: how to copy files (a repository) not from a git server, but rather from the host operating system's filesystem?