Maven是一个强大的项目管理与构建工具,使用maven构建docker镜像,工作也简化了很多。
这里我使用了docker-maven-plugin插件。
第一步:打开docker远程API端口
我的是centos7系统,需要修改的文件是/usr/lib/systemd/system/docker.service 文件
vim /usr/lib/systemd/system/docker.service
如下是我的配置文件,需要添加的部分是在第12行:ExecStart=/usr/bin/dockerd的后面加上-H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock,ok之后 :wq ,保存并退出。注意的是0.0.0.0,你没看错,这样配置就行,并不是自己的主机ip
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/us