docker-machine学习

已经学习了docker和docker-compose的使用,这两个工具都是在local使用的,如果远程的话就需要docker-machine和docker-swarm了。先从docker-machine学习一下。
参考:
https://www.jianshu.com/p/7bc0bdc67bbc
https://www.jianshu.com/p/0d9659080bd5
https://www.jianshu.com/p/a40c07f9f456

安装docker-machine

base=https://github.com/docker/machine/releases/download/v0.16.0 &&
curl -L $base/docker-machine-$(uname -s)-$(uname -m) >/tmp/docker-machine &&
sudo mv /tmp/docker-machine /usr/local/bin/docker-machine &&
chmod +x /usr/local/bin/docker-machine

或者去https://github.com/docker/machine/releases/
直接下载最新的版本

设置SSH密钥

ssh-keygen -b 2048 -t rsa 不要输入passphrase
ssh-copy-id root@localhost

创建machine

docker-machine create --driver generic --generic-ssh-user "ssh-user" --generic-ip-address=localhost d1
命令执行正常时的显示:

Running pre-create checks…
Creating machine…
(d1) No SSH key specified. Assuming an existing key at the default location.
Waiting for machine to be running, this may take a few minutes…
Detecting operating system of created instance…
Waiting for SSH to be available…
Detecting the provisioner…
Provisioning with ubuntu(systemd)…
Installing Docker…
Copying certs to the local machine directory…
Copying certs to the remote machine…
Setting Docker configuration on the remote daemon…
Checking connection to Docker…
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env d1

如果命令出现问题,可以增加--debug选项,查找出现问题的原因:
docker-machine --debug create --driver generic --generic-ssh-user "ssh-user" --generic-ip-address=localhost d1

管理主机

eval $(docker-machine env d1)

镜像加速

网上的多数方法都是修改目录/etc/docker/daemon.json文件,但是我没有找到这个文件,所以就修改了/etc/default/docker文件:DOCKER_OPTS="--registry-mirror=http://xxxxxxxx.m.daocloud.io"

安装cAdvisor

参考:https://www.jianshu.com/p/91f9d9ec374f

安装可视化管理工具 - Portainer

参考:
Portainer实战
Docker系列教程13-Docker可视化管理工具
Portainer 容器管理
docker pull portainer/portainer && docker run -d -e CAP_HOST_MANAGEMENT=1 --restart=always -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock portainer/portainer
安装后把国内的registry:daocloud.io

安装容器监控报警系统

从零搭建Prometheus监控报警系统
Prometheus入门到放弃(4)之cadvisor监控docker容器
docker:快速构建容器监控系统cAdvisor+InfluxDB+Grafana
cAdvisor+Prometheus+Grafana监控docker
Grafana与Elasticsearch
容器领域的十大监控系统对比

问题

  • 在WSL中没有找到ssh-keygen命令,apt-cache search ssh-keygen
  • 安装Docker的时候真的非常慢,查看网络的命令sar -n DEV 1 2dstatiftopiptrafnethogs;可以考虑使用--engine-install-url "http://acs-public-mirror.oss-cn-hangzhou.aliyuncs.com/docker-engine/internet",没有测试,参考https://www.alibabacloud.com/help/zh/doc-detail/44779.htm
发布了25 篇原创文章 · 获赞 1 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/fleaxin/article/details/103542254
今日推荐