docker初心者ですがdocker触ってみたくなったので。
id=”目次”>目次
CentOS7 にdockerインストール
7だと公式リポジトリで普通に突っ込めるようですが、
## yum info docker 利用可能なパッケージ 名前 : docker アーキテクチャー : x86_64 エポック : 2 バージョン : 1.13.1 リリース : 74.git6e3bb8e.el7.centos 容量 : 16 M リポジトリー : extras/7/x86_64 要約 : Automates deployment of containerized applications URL : https://github.com/docker/docker ライセンス : ASL 2.0 説明 : Docker is an open-source engine that automates the deployment of any : application as a lightweight, portable, self-sufficient container that will : run virtually anywhere. : : Docker containers can encapsulate any payload, and will run consistently on : and between virtually any server. The same container that a developer builds : and tests on a laptop will run at scale, in production*, on VMs, bare-metal : servers, OpenStack clusters, public instances, or combinations of the above.
わー、ふるーい。
公式のドキュメント見ながら入れていきます。
まずは必要なパッケージを入れて、古いdockerがあれば削除します。
# yum -y install lvm2 device-mapper device-mapper-persistent-data device-mapper-event device-mapper-libs device-mapper-event-libs # yum -y remove docker-common docker container-selinux docker-selinux docker-engine
リポジトリを追加します。
# wget https://download.docker.com/linux/centos/docker-ce.repo -O /etc/yum.repos.d/docker-ce.repo
準備できたのでdockerをインストールします。
# yum install docker-ce ======================================================================================================================================================================== Package アーキテクチャー バージョン リポジトリー 容量 ======================================================================================================================================================================== インストール中: docker-ce x86_64 18.06.1.ce-3.el7 docker-ce-stable 41 M 依存性関連でのインストールをします: container-selinux noarch 2:2.68-1.el7 extras 36 k 依存性関連での更新をします: libselinux x86_64 2.5-12.el7 base 162 k libselinux-devel x86_64 2.5-12.el7 base 186 k libselinux-python x86_64 2.5-12.el7 base 235 k libselinux-utils x86_64 2.5-12.el7 base 151 k libsemanage x86_64 2.5-11.el7 base 150 k libsemanage-python x86_64 2.5-11.el7 base 112 k libsepol x86_64 2.5-8.1.el7 base 297 k libsepol-devel x86_64 2.5-8.1.el7 base 77 k policycoreutils x86_64 2.5-22.el7 base 867 k policycoreutils-python x86_64 2.5-22.el7 base 454 k selinux-policy noarch 3.13.1-192.el7_5.6 updates 453 k selinux-policy-targeted noarch 3.13.1-192.el7_5.6 updates 6.6 M setools-libs x86_64 3.3.8-2.el7 base 619 k トランザクションの要約 ======================================================================================================================================================================== 完了しました!
バージョン確認します。
# docker --version Docker version 18.06.1-ce, build e68fc7a
わーい、あたらしー!
後、dockerと競合するので、firewalld切れとのこと。
# systemctl stop firewalld # systemctl disable firewalld
起動と自動起動設定して、ちゃんと動くかテストを実施します。
# docker run -it centos echo Hello-World Unable to find image 'centos:latest' locally latest: Pulling from library/centos 256b176beaff: Pull complete Digest: sha256:6f6d986d425aeabdc3a02cb61c02abb2e78e57357e92417d6d58332856024faf Status: Downloaded newer image for centos:latest Hello-World
docker動いたようです。
これで暫くは遊んでいようと思います。
root以外のユーザーでdockerを実行出来るようにする
こちらも一応やっておきます。
# groupadd docker # usermod -aG docker user1 # su - user1 $ docker run -it centos echo Hello-World Hello-World
これでroot以外のユーザーでのdockerを実行できます。