docker证书问题和docker虚拟机中安装docker-compose
问题缘由
本来是 docker 虚拟机运行着好好的,突然报错:
Unable to query docker version: Get https://192.168.99.100:2376/v1.15/version: x509: certificate has expired or is not yet valid很显然可以看到
certificate has expired
字样,网上查了半天,docker-machine regenerate-certs
和docker-machine provision
命令都试过了,没有作用。还有人说重建虚拟机,想想应该一定是有作用,但是里面的东西都要重建,很麻烦。发现docker-machine ssh
是正常的,那就干脆 ssh 到虚拟机里面去操作。docker虚拟机里面没有
docker-compose
,那就装一个,倒也不麻烦。按照官方的指导,两个命令搞定sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
接下来的麻烦 后来才意识到,docker虚拟机重启以后,就要重新安装
docker-compose
,它这个虚拟机是不保留状态的呀!这一长串的命令,就只好记到我的 commands.txt 里面去,每次用的时候去找出来复制粘贴(我把常用的命令什么的都记在这个文件中,加上 Sublime ,基本还是能很快找到想要用的命令)。另外一个事,许多容器没设置成自动启动,虚拟机重启以后,需要一一去启动,也是一样,记下来,用的时候找出来复制粘贴。
docker-compose -f /Users/mike/Projects/docker/mysql/docker-compose.yml restart
docker-compose -f /Users/mike/Projects/docker/redis/docker-compose.yml restart
docker-compose -f /Users/mike/Projects/docker/www1/docker-compose.yml restart
docker-compose -f /Users/mike/Projects/docker/www2/docker-compose.yml restart
docker-compose -f /Users/mike/Projects/docker/myadmin/docker-compose.yml restart
docker-compose -f /Users/mike/Projects/docker/nginx/docker-compose.yml restart
解决复制粘贴命令的烦恼 最近开始用 flashops ,立马想到,这些命令都弄到 flashops 里面去。有个小问题,就是得把 docker 虚拟机的 ssh 证书找出来,直接上结果,在这里:
/Users/mike/.docker/machine/machines/default/id_rsa先上一下 flashops 配置
servers:
- title: Docker Machine Default
ssh:
host: 192.168.99.100
user: docker
keyfile: /Users/mike/.docker/machine/machines/default/id_rsa
operations:
- title: Install Docker-Compose
commands:
- 'sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose'
- 'sudo chmod +x /usr/local/bin/docker-compose'
- title: Start all container
commands:
- 'docker-compose -f /Users/mike/Projects/docker/mysql/docker-compose.yml restart'
- 'docker-compose -f /Users/mike/Projects/docker/redis/docker-compose.yml restart'
- 'docker-compose -f /Users/mike/Projects/docker/www1/docker-compose.yml restart'
- 'docker-compose -f /Users/mike/Projects/docker/www2/docker-compose.yml restart'
- 'docker-compose -f /Users/mike/Projects/docker/myadmin/docker-compose.yml restart'
- 'docker-compose -f /Users/mike/Projects/docker/nginx/docker-compose.yml restart'
- 'docker ps'
再看一下整个执行过程
$ flashops
Hi, flashops
No config file provided, using FLASHOPS_FILE. -h to see the help.
File: /Users/mike/ds.yaml
[f] Files
[r] Projects
[s] Servers
[t] Tasks
[c] Statements
[D] Donation
Please input your choice ("exit" for quit): s1
Connecting to Docker Machine Default ...... Work path: /home/docker
[0] Check connection
[1] Install Docker-Compose
[2] Start all container
[3] Docker PS
(Docker Machine Default)Choose a Operation: 1
sudo curl -L https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
% Total% Received % XferdAverage SpeedTimeTimeTimeCurrent
DloadUploadTotalSpentLeftSpeed
10061706170010800 --:--:-- --:--:-- --:--:--1078
100 11.2M100 11.2M001070k00:00:100:00:10 --:--:-- 1329ksudo chmod +x /usr/local/bin/docker-compose(Docker Machine Default)Choose a Operation: 2
docker-compose -f /Users/mike/Projects/docker/mysql/docker-compose.yml restart
Restarting mysql_mysql_1 ... donedocker-compose -f /Users/mike/Projects/docker/redis/docker-compose.yml restart
Restarting redis_redis_1 ... donedocker-compose -f /Users/mike/Projects/docker/www1/docker-compose.yml restart
Restarting www1_www_1 ... donedocker-compose -f /Users/mike/Projects/docker/www2/docker-compose.yml restart
Restarting www2_www_1 ... donedocker-compose -f /Users/mike/Projects/docker/myadmin/docker-compose.yml restart
Restarting myadmin_myadmin_1 ... donedocker-compose -f /Users/mike/Projects/docker/nginx/docker-compose.yml restart
Restarting nginx_nginx_1 ... donedocker ps
CONTAINER IDIMAGECOMMANDCREATEDSTATUSPORTSNAMES
576e3033a294nginx_nginx"nginx -g 'daemon of…"2 months agoUp Less than a second0.0.0.0:80->80/tcpnginx_nginx_1
78f5013aa9d0myadmin_myadmin"catalina.sh jpda run"2 months agoUp 5 seconds0.0.0.0:10080->8080/tcpmyadmin_myadmin_1
f128d0e01bfdwww1_www"sh -c 'node www.js …"2 months agoUp 8 seconds0.0.0.0:6081->3000/tcpwww1_www_1
6e33edbfc3d2www2_www"sh -c 'node www.js …"2 months agoUp 6 seconds0.0.0.0:6082->3000/tcpwww2_www_1
298ae06c915cmysql_mysql"/entrypoint.sh mysq…"2 months agoUp 9 seconds0.0.0.0:3306->3306/tcpmysql_mysql_1
6950e6bcf2e9redis"/entrypoint.sh redi…"2 months agoUp 8 minutes0.0.0.0:6379->6379/tcpredis_redis_1(Docker Machine Default)Choose a Operation:
整个操作,只输入了
s1
1
2
比起到 commands.txt 里去找命令、复制粘贴舒服多了。
最后 【docker证书问题和docker虚拟机中安装docker-compose】再说一下 docker 虚拟机证书的问题,最后我还是重建了 docker 虚拟机(重建里面的容器什么的倒是容易的,就是导入数据库太慢,电脑不给力啊,足足等了一个多小时)。
推荐阅读
- parallels|parallels desktop 解决网络初始化失败问题
- Docker应用:容器间通信与Mariadb数据库主从复制
- jhipster|jhipster 升级无效问题
- “精神病患者”的角度问题
- 解决SpringBoot引用别的模块无法注入的问题
- Hive常见问题汇总
- 姚老师互动问答会|姚老师互动问答会 # 问题001(如何更有智慧的和身边人分享金刚智慧())
- 【Hadoop踩雷】Mac下安装Hadoop3以及Java版本问题
- 【教育故事】|【教育故事】 一个“问题学生”的蜕变
- 蓝桥杯试题