Open snnwolf opened 4 years ago
Thank you for opening the ticket! I'd love to learn more about your image and your use cases, so we can figure out what can be done. I noticed you install node.js and pm2 and I also noticed the expose Dockerfile instruction. Is there an app hiding somewhere or is it just a base image?
Yes, is external app with mount point.
This is docker-compose.ini
:
version: '3.1'
services:
prodcat:
image: t2/bo
restart: "no"
working_dir: /app
user: "bercut"
volumes:
- "/home/$USER/.ssh:/home/bercut/.ssh:ro"
- "./:/app"
environment:
REDIS_HOST: "redis"
command: >
sudo ssh -f -N -L 5080:192.168.17.98:5080 bercut@192.168.6.41 -i /home/bercut/.ssh/identity -oBatchMode=yes -oStrictHostKeyChecking=no -oConnec
sudo ssh -f -N -L 8083:192.168.6.33:8083 bercut@192.168.6.41 -i /home/bercut/.ssh/identity -oBatchMode=yes -oStrictHostKeyChecking=no -oConnect
sudo ssh -f -N -L 8100:192.168.12.194:8100 bercut@192.168.6.41 -i /home/bercut/.ssh/identity -oBatchMode=yes -oStrictHostKeyChecking=no -oConne
pm2-dev start ecosystem.config.js --env local"
@snnwolf Thanks for the extra details! It's definitely helpful! I'm curious about the app design and how those ssh
commands are related to what the app is doing.
This is an interesting setup for a few reasons (e.g., mounting the app code).
Either way, with a setup like this you also need to tell docker-slim
about the runtime parameters you have in your compose file, so the docker-slim
command would look something like this: docker-slim build t2/bo --mount '/home/$USER/.ssh:/home/bercut/.ssh:ro' --mount './:/app' --env 'REDIS_HOST=redis' --workdir=/app
. Can you try that to see what you get this time?
Report with different parameters: https://pastebin.com/pMrzzuZx PS: docker-slim from release
$ dive t2/bo
Report with docker-slim from git: https://pastebin.com/CLbKQjJD
dive
result is same: size 7.1 Mb
@snnwolf Thanks for retesting! Sorry, just realized that I missed the cmd
part of the command in my last comment... Can you try running this command: docker-slim build --mount '/home/$USER/.ssh:/home/bercut/.ssh:ro' --mount './:/app' --env 'REDIS_HOST=redis' --workdir=/app --cmd 'pm2-dev start ecosystem.config.js --env local' t2/bo
Either way, let me try to repro the condition with a similar design too...
Greate! It's work in simple running! I will testing in long time working! Thanks! Good work!!! Report log (pastebin) & slim.report.json.gz
BTW params for your command working with double quote (") not sinle ('):
docker-slim build --mount "/home/$USER/.ssh:/home/bercut/.ssh:ro" --mount "$(pwd):/app" --env 'REDIS_HOST=redis'--workdir=/app --cmd 'pm2-dev start ecosystem.config.js --env local' t2/bo
In other variants I look at error report
PS. Sorry, not all working :( I was try running multi commands by
command: >
bash -c "sudo ssh -f -N -L 80:apimnsms.bercut.com:80 bercut@192.168.6.41 -i /home/bercut/.ssh/identity -oBatchMode=yes -oStrictHostKeyChecking=no -oConnectTimeout=3 &&
sudo ssh -f -N -L 4711:192.168.17.146:4711 bercut@192.168.6.41 -i /home/bercut/.ssh/identity -oBatchMode=yes -oStrictHostKeyChecking=no -oConnectTimeout=3 &&
sudo ssh -f -N -L 5080:192.168.17.98:5080 bercut@192.168.6.41 -i /home/bercut/.ssh/identity -oBatchMode=yes -oStrictHostKeyChecking=no -oConnectTimeout=3 &&
sudo ssh -f -N -L 8083:192.168.6.33:8083 bercut@192.168.6.41 -i /home/bercut/.ssh/identity -oBatchMode=yes -oStrictHostKeyChecking=no -oConnectTimeout=3 &&
sudo ssh -f -N -L 8100:192.168.12.194:8100 bercut@192.168.6.41 -i /home/bercut/.ssh/identity -oBatchMode=yes -oStrictHostKeyChecking=no -oConnectTimeout=3 &&
pm2-dev start ecosystem.config.js --env local"
ERROR: for prodcat Cannot start service prodcat: OCI runtime create failed: container_linux.go:349: starting container process caused "exec: \"bash\": executable file not found in $PATH": unknown
PS2. I'm so sorry. It's working with run build with multicommand. Thanks. 🙏🙏🙏
docker-slim build --mount "/home/$USER/.ssh:/home/bercut/.ssh:ro" --mount "$(pwd):/app" \
--env 'REDIS_HOST=redis' --workdir=/app \
--cmd 'sh -c "sudo ssh -q 192.168.6.41 -l bercut -i /home/bercut/.ssh/identity -oBatchMode=yes -oStrictHostKeyChecking=no -oConnectTimeout=3 \"echo 'ok'; exit\" && pm2-dev start ecosystem.config.js --env local"' t2/bo
I have erron in other Docker image.
On build I copy *.sh files from big archive. With one of them on starting calling cat
like
cat /dev/null > "$CATALINA_PID"
Looks like /opt/BERClwsa/bin/catalina.sh: line 348: cat: command not found
catalina.sh
runing with ENTRYPOINT
command
My params for build slim image:
PS_DOCKER="/home/$USER/work/bercut/PS/SA ProductShowcase API/docker" docker-slim build --mount "${PS_DOCKER}/../out/artifacts:/app" --mount "${PS_DOCKER}/data:/data" --env local --entrypoint="/tmp/nosv_bootstrap.sh" t2/ps
slim.report.ps2.json.gz Image looks great (about 155 Mb). But sad mistrakes... :(
And run:
PS_DOCKER="/home/$USER/work/bercut/PS/SA ProductShowcase API/docker" docker run -it --rm -v "${PS_DOCKER}/../out/artifacts:/app" -v "${PS_DOCKER}/data:/data" t2/ps.slim
I using centos image link next:
dive
show next images:Result: I have no any system/installed programs like sudo, pm2...
slim report: slim.report.json.gz
dive report: t2-bo.tar.gz