slim
slim copied to clipboard
docker slim fails with "write unix @->/run/docker.sock: write: broken pip"
I am trying to slim a docker image that runs a simple python script.
Expected Behavior
Sucessfully makes a image that is slimmer or the same size as the image it is working on
Actual Behavior
Errs with
cmd=build info=build.error status='optimized.image.build.error' error='write unix @->/run/docker.sock: write: broken pipe'
cmd=build state=exited code=33554435 version=linux|Transformer|1.37.5|86fbd29ab3549fa564e87e4770178480cb0542d3|2022-03-21_06:10:20AM location=/usr/local/bin
Steps to Reproduce the Problem
I am trying to slim a docker image that runs a simple python script. A simple reproducible example. A Dockerfile with
FROM python:3.9-slim
RUN echo "print('Hello World!')" > ./main.py
CMD ["python", "main.py"]
and a bash script (make_slim.sh) to build the image and make sure it runs and slim the image:
sudo docker run $(sudo docker build -q ./)
echo "$(sudo docker build -q ./)"
sudo docker-slim build --target $(sudo docker build -q ./) --http-probe=false --exec "python main.py"
run bash script:
bash make_slim.sh
The full output is:
Hello World!
sha256:7d673146def32d263aa89ece6b351fee67cf7f251c659dd56953ba9b609ab663
docker-slim: message='join the Gitter channel to ask questions or to share your feedback' info='https://gitter.im/docker-slim/community'
docker-slim: message='join the Discord server to ask questions or to share your feedback' info='https://discord.gg/9tDyxYS'
docker-slim: message='Github discussions' info='https://github.com/docker-slim/docker-slim/discussions'
cmd=build info=exec message='changing continue-after from probe to nothing because http-probe is disabled'
cmd=build info=exec message='updating continue-after mode to exec'
cmd=build state=started
cmd=build info=params target.type='image' target='sha256:7d673146def32d263aa89ece6b351fee67cf7f251c659dd56953ba9b609ab663' continue.mode='exec' rt.as.user='true' keep.perms='true' tags=''
cmd=build state=image.inspection.start
cmd=build info=image id='sha256:7d673146def32d263aa89ece6b351fee67cf7f251c659dd56953ba9b609ab663' size.bytes='124714527' size.human='125 MB'
cmd=build info=image.stack index='0' name='python:3.9-slim' id='sha256:5da6ce3c33c6783782eece610be5c83a34001d6cd1d66ea32381afac543f366b'
cmd=build info=image.stack name='' id='sha256:7d673146def32d263aa89ece6b351fee67cf7f251c659dd56953ba9b609ab663' index='1'
cmd=build state=image.inspection.done
cmd=build state=container.inspection.start
cmd=build info=container status='created' name='dockerslimk_4807_20220828154425' id='5fed5015471129f2c55979223e838608272f4f4bc871fb02b5082122f411c520'
cmd=build info=container status='running' name='dockerslimk_4807_20220828154425' id='5fed5015471129f2c55979223e838608272f4f4bc871fb02b5082122f411c520'
cmd=build info=container message='obtained IP address' ip='172.17.0.2'
time="2022-08-28T16:44:26+01:00" level=error msg="channel.Client.Read: read error (read tcp 127.0.0.1:57958->127.0.0.1:49154: read: connection reset by peer), exiting..."
time="2022-08-28T16:44:26+01:00" level=error msg="channel.NewCommandClient: channel verify error = read tcp 127.0.0.1:57958->127.0.0.1:49154: read: connection reset by peer"
cmd=build info=cmd.startmonitor status='sent'
cmd=build info=event.startmonitor.done status='received'
cmd=build info=container name='dockerslimk_4807_20220828154425' id='5fed5015471129f2c55979223e838608272f4f4bc871fb02b5082122f411c520' target.port.list='' target.port.info='' message='YOU CAN USE THESE PORTS TO INTERACT WITH THE CONTAINER'
cmd=build info=continue.after mode='exec' message='provide the expected input to allow the container inspector to continue its execution'
cmd=build info=continue.after shell='python main.py' mode='exec'
docker-slim[build][exec]: output: Hello World!
cmd=build info=continue.after mode='exec' exitcode='0'
cmd=build state=container.inspection.finishing
cmd=build state=container.inspection.artifact.processing
cmd=build state=container.inspection.done
cmd=build state=building message="building optimized image"
cmd=build log='optimized.image.build' event=LOG.START tag='<none>.slim' ====================
cmd=build log='optimized.image.build' event=LOG.END tag='<none>.slim' ====================
cmd=build info=build.error status='optimized.image.build.error' error='write unix @->/run/docker.sock: write: broken pipe'
cmd=build state=exited code=33554435 version=linux|Transformer|1.37.5|86fbd29ab3549fa564e87e4770178480cb0542d3|2022-03-21_06:10:20AM location=/usr/local/bin
cmd=build info=container.inspector.cleanup name='dockerslimk_4807_20220828154425' id='5fed5015471129f2c55979223e838608272f4f4bc871fb02b5082122f411c520'
cmd=build state=container.target.shutdown.start
cmd=build info=container.inspector message='already finished monitoring'
cmd=build state=container.target.shutdown.done
cmd=build info=report file='slim.report.json'
docker-slim: message='join the Gitter channel to ask questions or to share your feedback' info='https://gitter.im/docker-slim/community'
docker-slim: message='join the Discord server to ask questions or to share your feedback' info='https://discord.gg/9tDyxYS'
docker-slim: message='Github discussions' info='https://github.com/docker-slim/docker-slim/discussions'
From the log, it seems that the --http-probe=false and --exec are working correctly, and the python script runs fine. So I'm confused what could be causing such a simple example to fail.
Specifications
OS:
- Version: 22.04.1 LTS
- Platform: Ubuntu
Docker:
- Version: Docker version 20.10.17, build 100c701
Docker-slim:
- Version: docker-slim version linux|Transformer|1.37.5|86fbd29ab3549fa564e87e4770178480cb0542d3|2022-03-21_06:10:20AM