slimtoolkit / slim

Slim(toolkit): Don't change anything in your container image and minify it by up to 30x (and for compiled languages even more) making it secure too! (free and open source)
Apache License 2.0
19.33k stars 725 forks source link

docker-slim build failed to run #695

Closed hcymysql closed 2 months ago

hcymysql commented 3 months ago

./docker-slim build --http-probe a0c63ef455bd

cmd=build info=param.http.probe message='using default probe' cmd=build state=started cmd=build info=params target.type='image' target.image='a0c63ef455bd' continue.mode='pr obe' rt.as.user='true' keep.perms='true' tags='' image-build-engine='internal' cmd=build state=image.inspection.start cmd=build info=image id='sha256:a0c63ef455bda5373460eeee75ddefe64faede4bb251cd2da88e7bc ceab85e73' size.bytes='2532901691' size.human='2.5 GB' cmd=build info=image.stack index='0' name='hcymysql/slowquery:2023-09-13' id='sha256:a0 c63ef455bda5373460eeee75ddefe64faede4bb251cd2da88e7bcceab85e73' cmd=build state=image.inspection.done cmd=build state=container.inspection.start cmd=build info=container name='slimk_6149_20240703075359' id='cbe969768f8623558fa2cf030 81b4d5c97b91ee8c369ceff6fd7ccdf4c5f1c93' status='created' cmd=build info=container status='running' name='slimk_6149_20240703075359' id='cbe96976 8f8623558fa2cf03081b4d5c97b91ee8c369ceff6fd7ccdf4c5f1c93' cmd=build info=container ip='172.17.0.2' message='obtained IP address' cmd=build info=cmd.startmonitor status='sent' cmd=build info=event.startmonitor.done status='received' cmd=build info=container message='YOU CAN USE THESE PORTS TO INTERACT WITH THE CONTAINE R' name='slimk_6149_20240703075359' id='cbe969768f8623558fa2cf03081b4d5c97b91ee8c369ceff6fd7ccdf4c5f1c93' target.port.list='1031,1032' target.port.info='3306/tcp => 0.0.0.0:1031,80/tcp => 0.0.0.0:1032' cmd=build state=http.probe.starting message="WAIT FOR HTTP PROBE TO FINISH" cmd=build info=continue.after message='no input required, execution will resume when HT TP probing is completed' mode='probe' cmd=build prompt='waiting for the HTTP probe to finish' cmd=build state=http.probe.running cmd=build info=http.probe.ports targets='1031,1032' count='2' cmd=build info=http.probe.commands count='1' commands='GET /' cmd=build info=http.probe.call error='Get "http://127.0.0.1:1031/": EOF' time='2024-07- 03T07:54:09Z' status='error' method='GET' target='http://127.0.0.1:1031/' attempt='1' cmd=build info=http.probe.call attempt='2' error='Get "http://127.0.0.1:1031/": read tcp 127.0.0.1:3083->127.0.0.1:1031: read: connection reset by peer' time='2024-07-03T07:54:25Z' status='error' method='GET' target='http://127.0.0.1:1031/' cmd=build info=http.probe.call attempt='3' error='Get "http://127.0.0.1:1031/": read tcp 127.0.0.1:3087->127.0.0.1:1031: read: connection reset by peer' time='2024-07-03T07:54:33Z' status='error' method='GET' target='http://127.0.0.1:1031/' cmd=build info=http.probe.call status='error' method='GET' target='http://127.0.0.1:1031/' attempt='4' error='Get "http:/ /127.0.0.1:1031/": read tcp 127.0.0.1:3091->127.0.0.1:1031: read: connection reset by peer' time='2024-07-03T07:54:41Z' cmd=build info=http.probe.call status='error' method='GET' target='http://127.0.0.1:1031/' attempt='5' error='Get "http:/ /127.0.0.1:1031/": read tcp 127.0.0.1:3095->127.0.0.1:1031: read: connection reset by peer' time='2024-07-03T07:54:49Z' cmd=build info=http.probe.call target='http://127.0.0.1:1032/' attempt='1' error='Get "http://127.0.0.1:1032/": read tcp 127.0.0.1:32505->127.0.0.1:1032: read: connection reset by peer' time='2024-07-03T07:54:57Z' status='error' method='GET' cmd=build info=http.probe.call status='error' method='GET' target='http://127.0.0.1:1032/' attempt='2' error='Get "http:/ /127.0.0.1:1032/": read tcp 127.0.0.1:32509->127.0.0.1:1032: read: connection reset by peer' time='2024-07-03T07:55:05Z' cmd=build info=http.probe.call target='http://127.0.0.1:1032/' attempt='3' error='Get "http://127.0.0.1:1032/": read tcp 127.0.0.1:32513->127.0.0.1:1032: read: connection reset by peer' time='2024-07-03T07:55:13Z' status='error' method='GET' cmd=build info=http.probe.call time='2024-07-03T07:55:21Z' status='error' method='GET' target='http://127.0.0.1:1032/' at tempt='4' error='Get "http://127.0.0.1:1032/": read tcp 127.0.0.1:32517->127.0.0.1:1032: read: connection reset by peer' cmd=build info=http.probe.call status='error' method='GET' target='http://127.0.0.1:1032/' attempt='5' error='Get "http:/ /127.0.0.1:1032/": read tcp 127.0.0.1:32521->127.0.0.1:1032: read: connection reset by peer' time='2024-07-03T07:55:29Z' cmd=build info=http.probe.summary total='10' failures='10' successful='0' cmd=build state=http.probe.done warning=no.successful.calls cmd=build info=event message='HTTP probe is done' cmd=build error=probe.error message='no.successful.calls' slim: container stdout: slim: container stderr: Couldn't find an alternative telinit implementation to spawn. slim: end of container logs ============= cmd=build state=exited code=-1 cmd=build info=container.inspector.cleanup name='slimk_6149_20240703075359' id='cbe969768f8623558fa2cf03081b4d5c97b91ee8c 369ceff6fd7ccdf4c5f1c93' cmd=build state=container.target.shutdown.start cmd=build state=container.target.shutdown.done cmd=build info=report file='slim.report.json' cmd=build info=exit code='-1' version='linux/amd64|Transformer|1.40.11|1b271555882eacdfb4e6598d6d0552e9b9b1449b|2024-02-0 2_01:36:22PM' location='/root/soft/dist_linux' app='slim' message='GitHub Discussions' info='https://github.com/slimtoolkit/slim/discussions' app='slim' message='Join the CNCF Slack channel to ask questions or to share your feedback' info='https://cloud-native.sl ack.com/archives/C059QP1RH1S'app='slim' message='Join the Discord server to ask questions or to share your feedback' info='https://discord.gg/9tDyxYS' app='slim' message='Join the Gitter channel to ask questions or to share your feedback' info='https://gitter.im/docker-sl im/community'

kcq commented 3 months ago

@hcymysql what's the full slimming CLI command you used? Also, how do you run the hcymysql/slowquery container (double checking that you run it with no parameters)? Can you provide an example (if you run it with parameters? What are the ports exposed by the container (ports 80 and 3306 are declared exposed, but are they really used)? What kind of network APIs are there? It looks like you have systemd configured in the image... Is it the case? And if so, what's the name of the systemd services that get started?

hcymysql commented 2 months ago

@hcymysql what's the full slimming CLI command you used? Also, how do you run the hcymysql/slowquery container (double checking that you run it with no parameters)? Can you provide an example (if you run it with parameters? What are the ports exposed by the container (ports 80 and 3306 are declared exposed, but are they really used)? What kind of network APIs are there? It looks like you have systemd configured in the image... Is it the case? And if so, what's the name of the systemd services that get started?

This is my Docker setup, LAMP (CentOS 7 + Apache + PHP + MariaDB):

Pull the Docker image docker.io/hcymysql/slowquery:2023-09-13.
1)docker pull docker.io/hcymysql/slowquery:2023-09-13

Run the Docker container in detached mode with interactive terminal, set the environment variable TERM=xterm-256color, grant additional privileges, name it slowquery, and map ports 80:80 and 3306:3306, using the command <IMAGE ID> /usr/sbin/init.
2) docker run -itd -e "TERM=xterm-256color" --privileged --name slowquery -p 80:80 -p 3306:3306 <IMAGE ID> /usr/sbin/init

Enter the Docker container slowquery interactively using /bin/bash.
3) docker exec -it slowquery /bin/bash

Start the Apache HTTP Server using systemctl start httpd.service.
4) systemctl start httpd.service 

I used:

docker-slim build --http-probe=false --expose 80 --expose 3306 --include-path=/var/www/html --include-path=/tmp --include-path=/data --include-path=/etc --include-path=/usr/ --include-bin=/usr/sbin/httpd --include-bin=/usr/libexec/mysqld --include-bin=/usr/bin/php --cmd "/usr/sbin/init"

docker exec -it slowquery /bin/bash

OCI runtime exec failed: exec failed: unable to start container process: exec: "/bin/bash": stat /bin/bash: no such file or directory: unknown

The webpage at http://192.168.137.131/slowquery/ failed to open.