美文网首页chimera
idea集成docker

idea集成docker

作者: 树荫下的天空 | 来源:发表于2018-12-13 20:03 被阅读19次

    安装docker插件

    image.png

    开放docker api 实现远程访问

    1. 修改/etc/sysconfig/docker文件,在最后增加一行DOCKER_OPTS,表明开放端口5555用作远程操作
         # docker-latest daemon can be used by starting the docker-latest unitfile. 
         # To use docker-latest client, uncomment below lines 
         #DOCKERBINARY=/usr/bin/docker-latest 
         #DOCKERDBINARY=/usr/bin/dockerd-latest 
         #DOCKER_CONTAINERD_BINARY=/usr/bin/docker-containerd-latest 
         #DOCKER_CONTAINERD_SHIM_BINARY=/usr/bin/docker-containerd-shim-latest 
         DOCKER_OPTS="-H unix:///var/run/docker.sock -H 0.0.0.0:5555"
    
    1. 修改/usr/lib/systemd/system/docker.service
      vim /usr/lib/systemd/system/docker.service
      在[Service]的ExexStart=下面增加一行$DOCKER_OPTS
         [Service]
         Type=notify
         NotifyAccess=all
         EnvironmentFile=-/etc/sysconfig/docker
         EnvironmentFile=-/etc/sysconfig/docker-storage
         EnvironmentFile=-/etc/sysconfig/docker-network
         Environment=GOTRACEBACK=crash
         Environment=DOCKER_HTTP_HOST_COMPAT=1
         Environment=PATH=/usr/libexec/docker:/usr/bin:/usr/sbin
         ExecStart=/usr/bin/dockerd-current \
                  --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
                  --default-runtime=docker-runc \
                  --exec-opt native.cgroupdriver=systemd \
                  --userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
                  $DOCKER_OPTS \
                  $OPTIONS \
                  $DOCKER_STORAGE_OPTIONS \
                  $DOCKER_NETWORK_OPTIONS \
                  $ADD_REGISTRY \
                  $BLOCK_REGISTRY \
                  $INSECURE_REGISTRY
    
    1. 用curl测试
      curl -v -X GET 主机ip:5555/images/json |python -m json.tool

    在IDEA中配置

    image.png

    常见问题

    • Docker启动时提示Failed to start docker.service: Unit docker.service is masked
      执行如下三条指令
      1. systemctl unmask docker.service
      2. systemctl unmask docker.socket
      3. systemctl start docker.service
    • 报http: server gave HTTP response to HTTPS client
      1. vim /usr/lib/systemd/system/docker.service
        image.png
      2. 在12行后面增加 --insecure-registry ip:5000
      3. 修改好后重启docker 服务
          systemctl daemon-reload
          systemctl restart docker
      

    相关文章

      网友评论

        本文标题:idea集成docker

        本文链接:https://www.haomeiwen.com/subject/vtevhqtx.html