k8sは僕の環境では大きすぎるので、
もっと手軽なwebguiを探したところ、
Portainerが良さげだったので使ってみます。
まずはDockerのインストールですが
Ubuntuの標準リポジトリだと古いので、
公式のものを使います。
$ sudo cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=18.04 DISTRIB_CODENAME=bionic DISTRIB_DESCRIPTION="Ubuntu 18.04.2 LTS"
インストールをはじめましょ
$ sudo apt-get install \ apt-transport-https \ ca-certificates \ curl \ gnupg-agent \ software-properties-common $ $ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - $ $ sudo apt-key fingerprint 0EBFCD88 pub rsa4096 2017-02-22 [SCEA] 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88 uid [ unknown] Docker Release (CE deb) <docker@docker.com> sub rsa4096 2017-02-22 [S] $ $ sudo add-apt-repository \ "deb [arch=amd64] https://download.docker.com/linux/ubuntu \ $(lsb_release -cs) \ stable" $ $ sudo apt-get update $ $ sudo apt-get install docker-ce docker-ce-cli containerd.io $ $ sudo docker -v Docker version 18.09.1, build 4c52b90
ここまででDockerのインストールはおしまい。
ホストを再起動したら落ちてしまうので、
対策として、
$ sudo systemctl enable docker.service Synchronizing state of docker.service with SysV service script with /lib/systemd/systemd-sysv-install. Executing: /lib/systemd/systemd-sysv-install enable docker
これで再起動してもDocker自体は動いてくれます。
次にPortainerをインストールします、
というかこれもDockerコンテナで動かします。
公式に従って。。。
ホストのDcokerソケットをコンテナにそのままマウントして、
ポートは9000でリダイレクトしています。
ぼくは、restart=alwaysで再起動してもコンテナを起動するようにしました。
https://www.portainer.io/installation/
$ docker volume create portainer_data portainer_data $ $ docker run -d -p 9000:9000 --name portainer --restart=always -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer Unable to find image 'portainer/portainer:latest' locally latest: Pulling from portainer/portainer d1e017099d17: Pull complete 74a417ed7ac5: Pull complete Digest: sha256:ac9aeaf784962573baf26c03cd9709114d7fbfe7e5bd690b1f8e3b46642e67ea Status: Downloaded newer image for portainer/portainer:latest 7a610b21f8b4547d35aed2a2def85a22d67579db263d6530fb313b98458b02cc $
これで終わり!!
あとは
http://Docker:9000
にアクセスすると使えます。
「Add Container」
でコンテナを作るときに、
Advanced container settings
Console
Interactive & TTY (-i -t)
を選択しないと上がらないので注意。
こんな感じ
$ sudo docker ps CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES f357d09873d9 portainer/portainer "/portainer" 3 minutes ago Up 3 minutes 0.0.0.0:9000->9000/tcp jolly_wright $ $ sudo docker info Containers: 1 Running: 1 Paused: 0 Stopped: 0 Images: 1 Server Version: 18.09.1 Storage Driver: overlay2 Backing Filesystem: extfs Supports d_type: true Native Overlay Diff: true Logging Driver: json-file Cgroup Driver: cgroupfs Plugins: Volume: local Network: bridge host macvlan null overlay Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog Swarm: inactive Runtimes: runc Default Runtime: runc Init Binary: docker-init containerd version: 9754871865f7fe2f4e74d43e2fc7ccd237edcbce runc version: 96ec2177ae841256168fcf76954f7177af9446eb init version: fec3683 Security Options: apparmor seccomp Profile: default Kernel Version: 4.15.0-45-generic Operating System: Ubuntu 18.04.2 LTS OSType: linux Architecture: x86_64 CPUs: 4 Total Memory: 3.852GiB Name: docker ID: TW4B:XWBF:EA7B:4FNO:E5QB:XNBB:VKOL:KQYU:PIKX:AKBK:KKFL:WSBY Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false Registry: https://index.docker.io/v1/ Labels: Experimental: false Insecure Registries: 127.0.0.0/8 Live Restore Enabled: false Product License: Community Engine WARNING: No swap limit support
コンテナを追加する場合は、
SOCKETではなくTCPなどが使えるので、
「-H tcp」を追加してあげます。
http://docs.docker.jp/engine/userguide/basics.html#docker-unix
# vi /lib/systemd/system/docker.service ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock -H tcp://0.0.0.0:2375
これで、ENDOPOINTを追加すればOK!
おわりー