LoginSignup
8
7

More than 5 years have passed since last update.

ubuntu-slimをベースにDockerイメージをつくるときに役立つコマンド

Last updated at Posted at 2016-10-05

bashやtopのような基本的なコマンドを入れながら色々と試行錯誤するときに役立ちそうなコマンドを書いておきます。

kubectl runでshコンテナ起動

name=sh-ubuntu-slim
image=gcr.io/google_containers/ubuntu-slim:0.4

# Waiting for   pod..を消すために--quiet
# https://github.com/kubernetes/kubernetes/issues/28695#issuecomment-231902836

# topコマンド等を動かすためにTERMを設定
# https://github.com/kubernetes/kubernetes/issues/28280

# --restart=NeverでCtrl-C時にリスタートしないようにする(なくてもリスタートしないみたいだけど一応)
# http://blog.kubernetes.io/2015/10/some-things-you-didnt-know-about-kubectl_28.html

kubectl run ${name} --image=${image} --quiet --rm -i --tty --restart=Never -- env "TERM=${TERM:-xterm}" sh

欲しいコマンドを含むaptパッケージを探す

$ apt-get update

# apt-fileはbashがないと実行時エラーになるのに、apt-get install apt-fileだけではインストールされないので、明示的にインストールしておく
$ apt-get install apt-file bash -y

$ apt-file update

$ apt-file search --regex '/top$'
broctl: /usr/share/broctl/scripts/helpers/top
crossfire-maps: /usr/share/games/crossfire/maps/santo_dominion/magara/well/top
crossfire-maps-small: /usr/share/games/crossfire/maps/santo_dominion/magara/well/top
liece: /usr/share/emacs/site-lisp/liece/styles/top
lubuntu-extra-sessions: /usr/share/lxpanel/profile/Lubuntu-Nexus7/panels/top
lxpanel: /etc/xdg/lxpanel/two_panels/panels/top
procps: /usr/bin/top
quilt: /usr/share/quilt/top
trn4: /usr/share/doc/trn4/examples/univ/top
trn4: /usr/share/trn4/HelpFiles/top

# topコマンドが含まれているのはprocpsなので、それをインストール
$ apt-get instal procps

開発時に必要なパッケージ

これくらいは入れておくと良いです。

$ apt-get update && \
  apt-get install -y curl bash apt-file vim jq && \
  curl -O https://storage.googleapis.com/kubernetes-release/release/v1.3.6/bin/linux/amd64/kubectl && \
  chmod +x kubectl && \
  mv kubectl /usr/local/bin/kubectl && \
  https://github.com/Yelp/dumb-init/releases/download/v1.1.3/dumb-init_1.1.3_amd64.deb -o dumb-init.deb && \
  dpkg -i dumb-init.deb
8
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
7