Dockerをインストール
$ sudo apt update
$ sudo apt install -y apt-transport-https ca-certificates curl software-properties-common
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$ sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
$ sudo apt update
$ sudo apt install -y docker-ce
$ sudo systemctl status docker
$ sudo docker ps
$ cat /etc/group | grep docker
$ sudo gpasswd -a kn docker
$ cat /etc/group | grep docker
$ sudo chmod 666 /var/run/docker.sock
$ docker ps
Docker-Compose をインストール
$ export compose='1.24.0'
$ sudo curl -L https://github.com/docker/compose/releases/download/${compose}/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
$ sudo chmod 0755 /usr/local/bin/docker-compose
$ docker-compose -v
Docker Registry をインストール
$ docker search registry
$ docker pull registry
$ docker images
$ docker run -d -p 5000:5000 registry
NginxのDockerImageを作成
$ mkdir docker-study
$ cd docker-study
$ vi Dockerfile
----------
# イメージの取得
FROM centos:latest
# 作成者情報
MAINTAINER 0.1 http://localhost/oldwp/
# Nginx用レポジトリファイルのコピー
ADD nginx.repo /etc/yum.repos.d/
# Nginxのインストール
RUN ["yum", "-y", "install", "nginx"]
# Nginxの自動起動設定
RUN ["systemctl", "enable", "nginx.service"]
----------
$ vi nginx.repo
----------
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
----------
$ docker build -t mynginx .
$ docker tag mynginx localhost:5000/nginx
$ docker images
作成したイメージをDocker Registry にPush
$ docker push localhost:5000/nginx
作成したイメージを削除
$ docker rmi mynginx
$ docker rmi localhost:5000/nginx
$ docker images
Docker Registryから pull してみる
$ docker pull localhost:5000/nginx
$ docker images
pull した nginx を起動
docker run --privileged --name "mynginx" -itd -p 8080:80 localhost:5000/nginx /sbin/init
参考URL
- https://qiita.com/morikooooo/items/9fd41bcd8d1ce9170301
- https://www.atmarkit.co.jp/flinux/rensai/linuxtips/164linendm.html
- https://kazuhisya.netlify.com/2016/02/14/docker-privileged-containers/
- https://qiita.com/mom0tomo/items/35dfacb628df1bd3651e
- https://qiita.com/Brutus/items/da63d23be32d505409c6
- https://qiita.com/iganari/items/fe4889943f22fd63692a
- https://qiita.com/gold-kou/items/44860fbda1a34a001fc1