ubuntu - docker安装及配置
2017-12-01 10:35
721 查看
前言
由于确实觉得windows下docker以及go的环境配置不爽,特意切换到linux进行go和docker的学习,今天记录一下docker在ubuntu的中的安装
过程
第一种deb安装包方式
下载deb https://download.docker.com/linux/ubuntu/dists/xenial/pool/stable/xenial替换为自己的ubuntu版本即可.
或者
https://download.docker.com/linux/ubuntu/dists从这个地址在一级级往下选也可以.
2.安装
sudo dpkg -i docker-ce_xxxx~ubuntu_amd64.deb
3.验证
docker –version
Docker version 17.09.0-ce, build afdb6d4(类似的结果)
docker阿里云镜像配置
打开登陆阿里云镜像官网 https://cr.console.aliyun.com
然后选择镜像加速器,就有对应的镜像加速地址和加速方式
sudo mkdir -p /etc/docker sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://pjirpg8s.mirror.aliyuncs.com"] } EOF sudo systemctl daemon-reload sudo systemctl restart docker
5.运行测试
sudo 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://cloud.docker.com/ For more examples and ideas, visit: https://docs.docker.com/engine/userguide/[/code]第二种在线安装
还可以使用添加repository的方式安装,
1.更新源
sudo apt-get update
2.添加apt的https支持
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
3.添加应用的GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
4.验证key
$ sudo apt-key fingerprint 0EBFCD88
5.添加repository
sudo add-apt-repository \
“deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable”
6.更新源
sudo apt-get update
7.安装
sudo apt-get install docker-ce
8.验证
sudo docker run hello-world配置
当我们就上述安装完成后,下次启动docker的时候就会出现权限问题。
ot permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Post http://%2Fvar%2Frun%2Fdocker.sock/v1.32/containers/create: dial unix /var/run/docker.sock: connect: permission denied.
这是由于我们当前的用户不在docker用户组,导致我们使用的时候每次都需要添加sudo,非常的不方便,接下来配置一下docker用户组。
1.添加docker用户组
sudo groupadd docker
2.将当前的用户添加到docker用户组
sudo gpasswd -a [username] docker
需要把[username]替换为你的用户名
3.重启docker服务
sudo service docker restart
4.切换回话到新的用户组
newgrp - docker补充
这里官方的文档
https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/#install-docker-ce-1
个人更加喜欢deb的方式,操作简单。
不好的地方就是需要自己手动更新#
与君共勉!!!
相关文章推荐
- ubuntu 上 docker 安装以及配置VNCserver
- virtualbox虚拟机ubuntu,安装docker,配置javaweb环境,简单实现负载均衡
- ubuntu16.10安装docker17.03.0-ce并配置国内源和加速器
- Ubuntu下安装Docker并配置Tomacat和jdk.
- 在ubuntu server中安装和配置docker
- ubuntu下安装配置部署zabbix——基于docker
- Ubuntu16.04.3安装Docker,配置镜像加速器及其基本使用
- ubuntu 16.04 安装docker-ce并配置加速器,让docker运行一个桌面系统
- ubuntu16.10安装docker17.03.0-ce并配置
- Docker 安装配置 in Ubuntu
- Docker 安装、配置教程 Ubuntu
- Ubuntu Docker 安装和配置 GitLab CI 持续集成
- Ubuntu下安装配置Docker简要笔记
- Ubuntu安装配置Docker和Docker-compose
- 在Ubuntu(16.04)下进行基于Docker的Discourse安装及基本配置
- Ubuntu17.04安装Docker17.06后配置国内(Docker中国官方)镜像加速
- ubuntu安装docker与配置
- ubuntu下安装配置部署zabbix3.0――基于docker
- ubuntu下安装配置部署zabbix——基于docker