Docker配置文件

非root用户管理docker

usermod -aG docker $USER

    [root@linux-node2 ~]# useradd docker_user1
    [root@linux-node2 ~]# su - docker_user1 
    [docker_user1@linux-node2 ~]$ docker run hello-world
    docker: Got permission denied while trying to connect to the Docker daemon socket a///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.38/containers/creal unix /var/run/docker.sock: connect: permission denied.
    See 'docker run --help'.
    [docker_user1@linux-node2 ~]$ logout
    [root@linux-node2 ~]# usermod -aG docker docker_user1 
    [root@linux-node2 ~]# id docker_user1
    uid=1000(docker_user1) gid=1000(docker_user1) groups=1000(docker_user1),993(docker)
    [root@linux-node2 ~]# su - docker_user1 
    Last login: Wed Oct 31 13:01:34 CST 2018 on pts/0
    [docker_user1@linux-node2 ~]$ docker run hello-world
    
    Hello from Docker!
    This message shows that your installation appears to be working correctly.
    
    To generate this message, Docker took the following steps:
     1. The Docker client contacted the Docker daemon.
     2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
        (amd64)
     3. The Docker daemon created a new container from that image which runs the
        executable that produces the output you are currently reading.
     4. The Docker daemon streamed that output to the Docker client, which sent it
        to your terminal.
    
    To try something more ambitious, you can run an Ubuntu container with:
     $ docker run -it ubuntu bash
    
    Share images, automate workflows, and more with a free Docker ID:
     https://hub.docker.com/
    
    For more examples and ideas, visit:
     https://docs.docker.com/get-started/

如果docker run hello-world报错如下:

    #报错
    WARNING: Error loading config file: /home/user/.docker/config.json -
    stat /home/user/.docker/config.json: permission denied
    #解决办法
    chown "$USER":"$USER" /home/"$USER"/.docker -R
    
    chmod g+rwx "$HOME/.docker" -R
docker配置远程访问
    #通过daemon.json文件,配置远程访问
    vim /etc/docker/daemon.json
    {
    "hosts": ["unix:///var/run/docker.sock", "tcp://127.0.0.1:2375"]
    }
    #重启docker
    systemctl restart docker.service
    #检查端口是否监听
    netstat -lntp | grep dockerd
    tcp        0      0 127.0.0.1:2375          0.0.0.0:*               LISTEN      3758/dockerd
为Docker指定DNS服务器
    vim /etc/docker/daemon.json
    {
    	"dns": ["8.8.8.8", "8.8.4.4"]
    }
    #重启docker
    systemctl restart docker.service
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值