最后更新于2022年4月6日 11:40:53
使用docker-ce和docker-compose进行镜像远程编译和部署
Troubleshootings
安装ssh-askpass
这里涉及到一步,通过docker context建立的SSH去远程访问remote host的containers,需要安装这个东西:sudo apt-get install ssh-askpass
,要不然没办法连接,会报错:ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory
docker-compose的选择
使用了docker-compose的1.28.0版本,因为docker-compose的1.29版本有问题,切换docker context use remote
是可以的,但是docker-compose up -d
会提示:
OpenSSL version mismatch. Built against 1010106f, you have 101000cf
我换成最新的docker-compose 2.4版本,ssh-askpass会报错什么cannot grab the keyboard什么的,没办法换成了1.28。
docker挂代理的问题
有些时候要从github或者别的网站下东西,docker就需要挂代理:
可以参考这个,在/etc/default/docker
目录下新建一个http-proxy.conf
文件。
2022年4月19日 09:37:43更新:
Docker的三种网络代理配置:这个问题比想象中的要复杂,我在/etc/systemd/system/docker.service.d
目录下也找到了http-proxy.conf
文件,同样可以控制代理。。
对上述文件进行修改,填入proxy信息如下:
[Service]
Environment="HTTP_PROXY=http://127.0.0.1:12333/"
Environment="HTTPS_PROXY=http://127.0.0.1:12333/"
然后重启docker:
systemctl restart docker.service
systemctl daemon-reload
systemctl restart docker.socket
Docker push报错
报这个错误:x509: certificate relies on legacy Common Name field, use SANs or temporarily enable Common Name matching with GODEBUG=x509ignoreCN=0
参考链接:Docker push to Gilab registry Self Signed Certs problem
解决方法:
You can also do the following. In /usr/lib/systemd/system/docker.service, add the following to [Service]
Environment=GODEBUG=x509ignoreCN=0
and reload/restart docker. You can also probably properly create /etc/systemd/system/docker.service.d/env.conf and put the following in a [Service] heading as well.
For non-systemd, just make sure that the above env var is set before starting docker.