LoginSignup
17

More than 1 year has passed since last update.

Barge使ってみた (Docker用軽量OS)

Last updated at Posted at 2016-10-31

ISOからboot

@A-I さんが作られた Bargeを使ってみた。

DISKの設定

fdisk /dev/vda

# swap
n p 1 enter +2G
t 82

# data
n p 2 enter enter

w

mkswap -L BARGE-SWAP /dev/vda1
mkfs.ext4 -L BARGE-DATA /dev/vda2
reboot

スクリーンショット 2016-10-31 13.55.46.png

IPの固定

sudo -s

ip addr add 192.168.0.2/24 dev eth0
ip route add default via 192.168.0.1
ip link set eth0 up
echo "nameserver 8.8.8.8" >> /etc/resolv.conf

スクリーンショット_2020-04-21_07-59-58.png
)

メモ

最新のdockerを使う

sudo /etc/init.d/docker restart latest

スクリーンショット_2020-04-21_07-42-17.png

DISKサイズを増やす

  • DISKイメージを拡張しておき、以下実施
# パーティションを削除し再度作成
fdisk /dev/vda
d 2
n p 2 enter enter
w

# OS再起動すると先ほどの設定を認識しなおす
reboot

# リサイズ実施
resize2fs /dev/vda2

スタートアップスクリプト

  • /etc/init.d/start.sh に記述する
/etc/init.d/start.sh
swapon /dev/vda1
chmod +x /etc/init.d/start.sh
reboot

ネットワーク設定

/etc/network/interfaces
# interface file auto-generated by buildroot

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
  address 192.168.100.56       
  netmask 255.255.255.0        
  gateway 192.168.100.1        

  pre-up /etc/network/nfs_check
  wait-delay 15                
  hostname $(hostname)         

  post-up cp /etc/resolv.conf.tail /etc/resolv.conf
  • /etc/resolv.conf が /tmp/resolv.conf にシンボリックリンクされている。

sshdのパスワード認証をやめる

/etc/ssh/sshd_config
- #PasswordAuthentication yes
+ PasswordAuthentication no
  • reboot

パッケージの追加

sudo pkg install vim
sudo pkg install git

日本標準時間(GMT-9)を使う

ln -s -f /usr/share/zoneinfo/Etc/GMT-9 /etc/localtime

docker-compose

# ダウンロード ※ 2系は動かない
## https://github.com/docker/compose/releases/tag/1.29.2

wget -O docker-compose "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-Linux-x86_64"

# 2.5.0だと以下
# wget -O docker-compose "https://objects.githubusercontent.com/github-production-release-asset-2e65be/15045751/ff4c52bc-2caf-4248-a74c-3df2accb02d9?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20220515%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220515T022317Z&X-Amz-Expires=300&X-Amz-Signature=28f0967362d1388e0ed4ab9fc5994fd5783664dda79e419b3270a1be8a5abefc&X-Amz-SignedHeaders=host&actor_id=0&key_id=0&repo_id=15045751&response-content-disposition=attachment%3B%20filename%3Ddocker-compose-linux-x86_64&response-content-type=application%2Foctet-stream"


chmod +x /opt/bin/docker-compose

# ダウンロード
sudo mv docker-compose /opt/bin/

cronも動いている

すでに crond が動いている。

crontab -e

* * * * * echo a >> /tmp

時刻を手で設定する方法

sudo date -s '2017-01-19 15:01'

設定ひかえ

/bargee.tar.gz
cd /

tar cfz bargee.tar.gz \
 /etc/init.d/start.sh \
 /etc/localtime \
 /etc/network/interfaces \
 /etc/ssh/sshd_config \
 /home/bargee/.ssh/authorized_keys

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
17