technology-note/linux/docker/1.linux下docker安装与配置.md

68 lines
1.5 KiB
Markdown
Raw Normal View History

---
id: "2018-11-20-10-38-05"
date: "2018/11/20 10:38:05"
title: "1.linux下mongodb的配置与安装"
2019-05-16 13:50:53 +08:00
tags: ["docker", "linux", "ubuntu"]
categories:
- "linux"
- "docker教程"
---
# 一、安装
2019-05-16 13:50:53 +08:00
  有两种安装方法,脚本安装和 apt 安装
## 1、脚本安装
2019-05-16 13:50:53 +08:00
  root 下执行以下命令(非 root 下会要求输入密码):
```bash
wget -qO- https://get.docker.com/ | sh
```
2019-05-16 13:50:53 +08:00
等待执行完毕后会有如下提示:
2019-05-16 13:50:53 +08:00
```
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:
sudo usermod -aG docker 用户名
2019-05-16 13:50:53 +08:00
Remember that you will have to log out and back in for this to take effect!
```
2019-05-16 13:50:53 +08:00
就是如果要以非 root 用户直接运行 docker 时需要执行`sudo usermod -aG docker 非root用户名`,然后重新登陆即可。
<!-- more -->
2019-05-16 13:50:53 +08:00
## 2、apt 安装
&emsp;&emsp;直接运行(root 下)
```bash
apt-get update
apt-get install docker.io
```
# 二、配置国内源
&emsp;&emsp;国外源太慢配置为国内源。修改或创建`/etc/docker/daemon.json`,内容如下:
2019-05-16 13:50:53 +08:00
```json
{
2019-05-16 13:50:53 +08:00
"registry-mirrors": ["加速地址"],
"insecure-registries": []
}
```
2019-05-16 13:50:53 +08:00
以下是国内加速地址:
2019-05-16 13:50:53 +08:00
- 网易 [http://hub-mirror.c.163.com](http://hub-mirror.c.163.com)
- ustc [https://docker.mirrors.ustc.edu.cn](https://docker.mirrors.ustc.edu.cn)
2019-05-16 13:50:53 +08:00
然后重启生效
```bash
sudo systemctl daemon-reload
sudo systemctl restart docker
```