Giter VIP home page Giter VIP logo

cpbp's Introduction

Container personal best practice

Dockerfile

delete extra softs each image layer

  • for ubuntu
...
RUN apt-get update && apt-get install -y --no-install-recommends libjemalloc1 && rm -rf /var/lib/apt/lists/*

RUN apt-get update \
	&& apt-get install -y cassandra="$CASSANDRA_VERSION" \
	&& rm -rf /var/lib/apt/lists/*
...

source of cassandra:2.2

  • for alpine
...
RUN apk add --update --no-cache \
    python \
    python-dev \
    py-pip \
    build-base \
  && pip install virtualenv \
  && rm -rf /var/cache/apk/*
...

reference

useful template

FROM
MAINTAINER

ENV FRESHED_AT 2017-01-17
# set timezone if possible
RUN ln -f -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

use proper software source if under GFW

for example,use aliyun source for ubuntu

deb http://mirrors.aliyun.com/ubuntu/ trusty main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-proposed main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ trusty-backports main restricted universe multiverse

Install common softwares

supervisor

  • ubuntu
apt-get update
apt-get install -yqq --no-install-recommends supervisor
  • python setuptools
apt-get install python-setuptools
easy_install supervisor

mesos

RUN echo "deb http://repos.mesosphere.io/ubuntu/ trusty main" > /etc/apt/sources.list.d/mesosphere.list && \
    apt-key adv --keyserver keyserver.ubuntu.com --recv E56151BF

docker

openjdk

by the time 2016.2.18, ubuntu 14.04 does not support to install openjdk8 by apt-get,use 14.10+ instead.

apt-get install openjdk-7-jre

reference:

make image small and light

use alpine as far as possible

ubuntu

  1. remove cache after update or installing softwares
sudo apt-get autoclean(已卸载软件的安装包)
sudo apt-get clean(未卸载软件的安装包)类似于 rm -rf /var/cache/apt/archives/*
sudo apt-get autoremove (清理系统不再需要的孤立的软件包)

--no-install-recommends

apt-get install -y --no-install-recommends vim

use pipe

RUN apt-get install -y curl && \
    curl -fL http://apache.fayea.com/zookeeper/zookeeper-3.3.6/zookeeper-3.3.6.tar.gz | tar xzf - -C /usr/local && \
    mv /usr/local/zookeeper-3.3.6 /usr/local/zookeeper

dockerfile

cpbp's People

Contributors

alwqx avatar

Watchers

James Cloos avatar  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.