I’m using docker images for my hosting of website.
They are VERY heavy. I made a try with docker-slim to reduce the weight (on one of the images, that were already generated prior, with docker-compose build)
it worked well, the weight was divided by 10. (I didn’t try yet if it works to run it, as I have other images too).
I’m on windows, so I’m using the dockerized version of docker-slim.
So I tried to minify the database image too. It failed because it didn’t get the env variables. (as a detail, I’m using a docker .env file)
Currently my goal is to either directly generate all the images in my docker-compose.yml (while considering also the .env file), or to first generate them with docker-compose build, then
all with docker-slim, while it would consider the docker-compose.yml.
I tried the option to make docker-slim consider also the .yml file:
docker run -it --rm -v /var/run/docker.sock:/var/run/docker.sock -v C:projectfolder:/data dslim/slim build --compose-file /data/docker/docker-compose.yml
But it gives me this :
cmd=build error=param.target message='missing image ID/name'
While I don’t think I should give the image name since they’re all in the docker-compose.yml file
What am I doing wrong? I feel like what I’m trying to do is a common usage. If I’m trying it the wrong way, please let me know
I also made a second attempt, running a “docker in docker” image, and installing slim in it. The build (of this image, not my web images) works fine.
However if I run it :
$ docker-compose -f docker-compose-slim.yml up
Container docker-docker-slim-1 Created
Attaching to docker-docker-slim-1
docker-docker-slim-1 | Certificate request self-signature ok
docker-docker-slim-1 | subject=CN=docker:dind server
docker-docker-slim-1 | /certs/server/cert.pem: OK
docker-docker-slim-1 | Certificate request self-signature ok
docker-docker-slim-1 | subject=CN=docker:dind client
docker-docker-slim-1 | /certs/client/cert.pem: OK
docker-docker-slim-1 | iptables v1.8.10 (legacy)
docker-docker-slim-1 | mount: permission denied (are you root?)
docker-docker-slim-1 exited with code 1
from the docker-compose.yml :
version: "3"
services:
docker-slim:
build:
context: ../
dockerfile: ./docker/slim/Dockerfile
volumes:
- ./:/data
And dockerfile:
FROM docker:latest
RUN apk --no-cache add curl bash
#RUN curl -sL https://raw.githubusercontent.com/slimtoolkit/slim/master/scripts/install-slim.sh | sudo -E bash -
RUN curl -sL https://raw.githubusercontent.com/slimtoolkit/slim/master/scripts/install-slim.sh | bash -
PS: if people have a feedback about how safe to use is docker-slim for production build, I’m interested (I’m not scared about vulnerabilities, but more like that it breaks something
and I don’t notice)