0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CentOS7にDockerを入れるための準備

Posted at

VirtualBox上でCentOS7.3をインストール済み。
Dockerで使用する領域を100GB分追加しておく。以下その手順。

[root@Dockh ~]# 
[root@Dockh ~]# fdisk -l

Disk /dev/sda: 32.5 GB, 32482787328 bytes, 63442944 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
Disk label type: dos
ディスク識別子: 0x000cd0e9

デバイス ブート      始点        終点     ブロック   Id  システム
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    63442943    30671872   8e  Linux LVM

Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
Disk label type: dos
ディスク識別子: 0x83836115

デバイス ブート      始点        終点     ブロック   Id  システム
/dev/sdb1            2048   209715199   104856576   83  Linux

Disk /dev/mapper/cl-root: 29.3 GB, 29255270400 bytes, 57139200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト


Disk /dev/mapper/cl-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト

[root@Dockh ~]#

GPTパーティションの作成。
パフォーマンスが出ないと。。。
割り切って無視して進む。

[root@Dockh ~]# parted -s /dev/sdb 'mklabel gpt'
[root@Dockh ~]# parted -s /dev/sdb 'mkpart primary 0 -1'
警告: 操作の結果できるパーティションはアライメントが正しくないためにパフォーマンスがでません。
[root@Dockh ~]# parted -s /dev/sdb 'print'
モデル: ATA VBOX HARDDISK (scsi)
ディスク /dev/sdb: 107GB
セクタサイズ (論理/物理): 512B/512B
パーティションテーブル: gpt
ディスクフラグ: 

番号  開始    終了   サイズ  ファイルシステム  名前     フラグ
 1    17.4kB  107GB  107GB                     primary

[root@Dockh ~]#
[root@Dockh ~]# fdisk -l

Disk /dev/sda: 32.5 GB, 32482787328 bytes, 63442944 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
Disk label type: dos
ディスク識別子: 0x000cd0e9

デバイス ブート      始点        終点     ブロック   Id  システム
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200    63442943    30671872   8e  Linux LVM
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト
Disk label type: gpt


#         Start          End    Size  Type            Name
 1           34    209713247    100G  Microsoft basic primary

Disk /dev/mapper/cl-root: 29.3 GB, 29255270400 bytes, 57139200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト


Disk /dev/mapper/cl-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O サイズ (最小 / 推奨): 512 バイト / 512 バイト

[root@Dockh ~]#
[root@Dockh ~]# partprobe /dev/sdb
[root@Dockh ~]# mkfs.xfs /dev/sdb1
meta-data=/dev/sdb1              isize=512    agcount=4, agsize=6553538 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0, sparse=0
data     =                       bsize=4096   blocks=26214151, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal log           bsize=4096   blocks=12799, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
[root@Dockh ~]# 

[root@Dockh ~]# mkdir /var/lib/docker
[root@Dockh ~]# vi /etc/fstab 
[root@Dockh ~]# 
[root@Dockh ~]# 
[root@Dockh ~]# cat /etc/fstab 

#
# /etc/fstab
# Created by anaconda on Tue Apr 18 22:19:00 2017
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/cl-root     /                       xfs     defaults        0 0
UUID=54c140f2-4149-44c6-80c3-a39272685300 /boot                   xfs     defaults        0 0
/dev/sdb1	/var/lib/docker	xfs	defaults	0 0
/dev/mapper/cl-swap     swap                    swap    defaults        0 0
[root@Dockh ~]# 
[root@Dockh ~]# mount -a
[root@Dockh ~]# 
[root@Dockh ~]# df -HT 
ファイルシス        タイプ   サイズ  使用  残り 使用% マウント位置
/dev/mapper/cl-root xfs         30G  997M   29G    4% /
devtmpfs            devtmpfs   510M     0  510M    0% /dev
tmpfs               tmpfs      521M     0  521M    0% /dev/shm
tmpfs               tmpfs      521M  6.9M  514M    2% /run
tmpfs               tmpfs      521M     0  521M    0% /sys/fs/cgroup
/dev/sda1           xfs        1.1G  145M  920M   14% /boot
tmpfs               tmpfs      105M     0  105M    0% /run/user/1000
/dev/sdb1           xfs        108G   34M  108G    1% /var/lib/docker
[root@Dockh ~]# 

無事にマウントまで完了。

とりあえずここでパッケージアップデートする。

[root@Dockh ~]# yum update -y
読み込んだプラグイン:fastestmirror
base                                                                                                  | 3.6 kB  00:00:00     
extras                                                                                                | 3.4 kB  00:00:00     
updates                                                                                               | 3.4 kB  00:00:00     
(1/4): base/7/x86_64/group_gz                                                                         | 155 kB  00:00:00     
(2/4): extras/7/x86_64/primary_db                                                                     | 139 kB  00:00:00     
(3/4): updates/7/x86_64/primary_db                                                                    | 4.7 MB  00:00:14  

   途中省略
      
  selinux-policy-targeted.noarch 0:3.13.1-102.el7_3.16           sudo.x86_64 0:1.8.6p7-21.el7_3                             
  systemd.x86_64 0:219-30.el7_3.8                                systemd-libs.x86_64 0:219-30.el7_3.8                       
  systemd-sysv.x86_64 0:219-30.el7_3.8                           tuned.noarch 0:2.7.1-3.el7_3.1                             
  tzdata.noarch 0:2017b-1.el7                                    util-linux.x86_64 0:2.23.2-33.el7_3.2                      
  vim-minimal.x86_64 2:7.4.160-1.el7_3.1                         wpa_supplicant.x86_64 1:2.0-21.el7_3                       
  xfsprogs.x86_64 0:4.5.0-9.el7_3                               

完了しました!
[root@Dockh ~]#            

FWの無効化。SELinuxもね。

[root@Dockh ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.
[root@Dockh ~]# 
[root@Dockh ~]# 
[root@Dockh ~]# vi /etc/sysconfig/selinux 
[root@Dockh ~]# cat /etc/sysconfig/selinux 

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
# SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted 


[root@Dockh ~]# 

一旦リブート

[root@Dockh ~]# reboot
0
1
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?