docker安装和使用过程中遇到的问题

来源:互联网 发布:电脑怎么修改淘宝评价 编辑:程序博客网 时间:2024/06/04 18:37

一、CentOs7上添加docker仓库时报错,大约是最新docker要求某些插件的版本比已经安装的该插件版本高。

解决方案:或许升级插件版本也能解决,我嫌麻烦,所以将仓库文件/etc/yum.repos.d/docker.repo中的baseurl中的7改成了6

[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/6/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg


二、使用另一台机器连接docker服务器时,docker服务器需要开放docker api,具体方法是:

在/ect/sysconfig/docker文件中添加other_args="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock"

表示开放2375端口。

同时因为这种开放端口的方式没有添加加密证书,是非常不安全的,所以还要求加个参数--insecure-registry 101.251.209.225:50000,最终如下

other_args="-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --insecure-registry 101.251.209.225:50000"


三、我在本地机器上构建的maven项目,我想为它创建镜像,但我本地机器wein7系统没有安装docker,我想把镜像创建到远程docker服务器上。怎么办呢?

<properties>    <docker.registry>192.168.100.12:50000</docker.registry> <!--用于将镜像push到仓库,50000是创建仓库时设置的主机端口--></properties>

<plugin>    <groupId>com.spotify</groupId>    <artifactId>docker-maven-plugin</artifactId>    <version>0.4.14</version>    <configuration>        <skipDockerBuild>false</skipDockerBuild>        <pushImage>true</pushImage>        <imageTags>            <imageTag>latest</imageTag>        </imageTags>        <imageName>${docker.registry}/${project.artifactId}:${project.version}</imageName>        <dockerDirectory>${project.build.outputDirectory}</dockerDirectory>        <!-- 解决Connect to localhost:2375的问题的其中一种方式,注意要跟docker-machine env相一致 -->        <dockerHost>http://IP:2375</dockerHost> <!--IP需要具体填写docker服务所在IP地址,该配置项解决远程创建docker镜像的问题-->        <dockerCertPath>C:\Users\admin\.docker\machine\machines\default</dockerCertPath>        <resources>            <resource>                <targetPath>/</targetPath>                <directory>${project.build.directory}</directory>                <include>${project.build.finalName}.jar</include>            </resource>        </resources>    </configuration></plugin>


原创粉丝点击