Giter Club home page Giter Club logo

docker-min-jessie's Introduction

docker-min-jessie

Updated minimally sized Debian Jessie build.

Usage

If you just want to use this image, pull it and configure what you want:

# docker pull monsantoco/min-jessie

To use this image in your own project, use this FROM line in your Dockerfile:

FROM monsantoco/min-jessie:latest

Building

Part of this process is documented in the Dockerfile, but the manual process is outlined here. Unfortunately, the Dockerfile approach is unable to actually make the image smaller because it retains the parent images. You need to docker-squash to actually make the image smaller. To our knowledge, there is no way to trick Docker Hub into doing this for you as part of its automatic build. So, you are stuck doing it by hand.

This recipe for creating a minimal Debian GNU/Linux image is based on Phil Cryer's recipe that can be found at https://registry.hub.docker.com/u/philcryer/min-wheezy/

Pull Original Image

First pull the official, larger Debian GNU/Linux image, in this case jessie.

# docker pull debian:jessie

Get Image ID

Run the command below get the image ID.

# docker images
REPOSITORY  TAG     IMAGE ID      CREATED     VIRTUAL SIZE
debian      8.0     0e30e84e9513  3 days ago  122.8 MB
debian      jessie  0e30e84e9513  3 days ago  122.8 MB
debian      8       0e30e84e9513  3 days ago  122.8 MB

Look for the ID of the image you just pulled. Above it would be 0e30e84e9513.

Run Container

Run the container interactively using the command below.

# docker run -it IMAGE_ID /bin/bash

Clean

Within the interactive container, run the following command.

# apt-get update && \
    apt-get upgrade -y && \
    apt-get clean -y && \
    apt-get autoclean -y && \
    apt-get autoremove -y && \
    rm -rf /usr/share/locale/* && \
    rm -rf /var/cache/debconf/*-old && \
    rm -rf /var/lib/apt/lists/* && \
    rm -rf /usr/share/doc/* && \
    exit

Get Container ID

Run the command

# docker ps -a
CONTAINER ID  IMAGE     COMMAND      CREATED         STATUS                     PORTS  NAMES
4d08ec826529  debian:8  "/bin/bash"  28 minutes ago  Exited (0) 47 seconds ago         berserk_sammet

and look for the ID of the container you were just running. In this case, the container ID is 4d08ec826529.

Commit Container

Run the command below to commit the container. If you are doing this yourself, you would replace monsantoco with your Docker Hub user or organization name.

# docker commit CONTAINER_ID monsantoco/min-jessie:latest

This creates an image from the container, but it still has layers with all the stuff we removed.

# docker images
REPOSITORY             TAG     IMAGE ID      CREATED         VIRTUAL SIZE
monsantoco/min-jessie  latest  2319ddb6394e  58 seconds ago  122.8 MB
debian                 8.0     0e30e84e9513  3 days ago      122.8 MB
debian                 jessie  0e30e84e9513  3 days ago      122.8 MB
debian                 8       0e30e84e9513  3 days ago      122.8 MB

It's the same size! So we need to squash it. Note the IMAGE_ID for your image above.

Squash Image

We squash the image using docker-squash. You will need to install that tool for this step. Use the IMAGE_ID for your image from the previous step.

# docker save IMAGE_ID | docker-squash -from root -t monsantoco/min-jessie | docker load

Now we can see that the image is smaller.

# docker images
REPOSITORY             TAG     IMAGE ID      CREATED         VIRTUAL SIZE
monsantoco/min-jessie  latest  d9211ded36f0  54 seconds ago  82.46 MB
debian                 8.0     0e30e84e9513  3 days ago      122.8 MB
debian                 jessie  0e30e84e9513  3 days ago      122.8 MB
debian                 8       0e30e84e9513  3 days ago      122.8 MB

Copyright

Copyright (c) 2015, Monsanto Company

License

This code is released under the modified BSD 3-clause license. See LICENSE file for details.

docker-min-jessie's People

Contributors

ddgenome avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.