Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amazon Linux Support #72

Open
Jinkxed opened this issue Mar 19, 2019 · 5 comments
Open

Amazon Linux Support #72

Jinkxed opened this issue Mar 19, 2019 · 5 comments
Labels

Comments

@Jinkxed
Copy link

Jinkxed commented Mar 19, 2019

Trying to test out docker-slim on amazonlinux base image and it's causes some very weird behavior. All binaries seem to be missing to start so can't even do ls

Example:
Dockerfile
FROM amazonlinux:latest
docker-slim build amazonlinux:latest

@kcq
Copy link
Member

kcq commented Mar 20, 2019

Do you have an application container image where you use the Amazon Linux as its base or are you trying to minify the base image itself?

@kcq kcq added the triage label Mar 20, 2019
@Jinkxed
Copy link
Author

Jinkxed commented Mar 29, 2019

Tried both and got the same results.

Sorry to be more explicit. I build an application container off the amazonlinux:latest container. I've tried running docker-slim on both the base and the application image and it seems to be broke on both.

When I say broke I basically mean there are no files / bin / all the application code or scripts are removed etc.

Easy way to reproduce is by running the above and just typing ls.

@kcq
Copy link
Member

kcq commented Apr 1, 2019

What kind of application did you have? Was it a python/ruby/node/java/something else app? What kind of ENTRYPOINT and/or CMD instructions did you have in your Dockerfile? Did you have a wrapper shell script that started your application and potentially did other things or did you invoke your application directly in ENTRYPOINT/CMD or did you have something like supervisord managing several processes in your container or maybe you used docker-compose where you configured the command parameters for your container?

@Jinkxed
Copy link
Author

Jinkxed commented May 23, 2019

Sorry didn't see this.

None of my applications use entrypoints only commands - most are rails apps. So just running bundle exec rails -s, but this issue happens on the official Amazon Linux image. So even without my customizations it seems to fail on just the base OS image.

@kcq
Copy link
Member

kcq commented May 23, 2019

@sc-chad thank you for the additional info! really appreciate it!

The base OS image is not a great container to minify because there's no way to know what you need there and what you don't in a significant way. You can leverage the --include-path, --include-shell, --include-exe and --include-bin parameters to tell docker-slim what you want to keep in your base image, but it requires a bit of extra work from you because you need to explicitly specify/decide what you want to keep.

Here's one of the sample apps docker-slim that might be interesting for you (I'd love to add more Rails examples, so if you have any good open source references i'd love to add them): https://github.com/docker-slim/examples/tree/master/ruby_rails_standard

A couple of things to note:

For Rails and Ruby apps in general docker-slim needs the --http-probe parameter when you are minifying the image: docker-slim build --http-probe my/ruby-rails-app (https://github.com/docker-slim/examples/blob/master/ruby_rails_standard/slim.command).

This is necessary to make sure that your Rails app loads extra dependencies it needs, which happens when you its handling HTTP requests.

docker-slim also needs to know about the port(s) your application is using. Normally your Dockerfile would have one or many EXPOSE instructions and docker-slim will see it leveraging it when it's running its HTTP probes (https://github.com/docker-slim/examples/blob/master/ruby_rails_standard/Dockerfile). If your Dockerfile doesn't have any EXPOSE instructions you need to tell docker-slim about your ports similar to how you need to tell docker about the ports you want to use when you execute the run command. With docker-slim it means using the --expose parameter: docker-slim build --http-probe --expose=5000 my/ruby-rails-app

If you are interested I'll be happy to do an online session to walk through your container setup, so we can get your app container minified. You'll get a small container and I'll have an opportunity to make docker-slim easier to use, so everybody wins :-) And if you have containerized Rails examples I'd love to add them to the examples repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants