Docker 配置

Docker

安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# step 1: 安装必要的一些系统工具
sudo yum install -y yum-utils device-mapper-persistent-data lvm2 firewalld
# Step 2: 添加软件源信息
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# Step 3: 更新并安装 Docker-CE
sudo yum makecache fast
sudo yum -y install docker-ce
# Step 4: 开启Docker服务
sudo service docker start

# 注意:
# Step 1: 查找Docker-CE的版本:
# yum list docker-ce.x86_64 --showduplicates | sort -r
# Loading mirror speeds from cached hostfile
# Loaded plugins: branch, fastestmirror, langpacks
# docker-ce.x86_64 17.03.1.ce-1.el7.centos docker-ce-stable
# docker-ce.x86_64 17.03.1.ce-1.el7.centos @docker-ce-stable
# docker-ce.x86_64 17.03.0.ce-1.el7.centos docker-ce-stable
# Available Packages
# Step2 : 安装指定版本的Docker-CE: (VERSION 例如上面的 17.03.0.ce.1-1.el7.centos)
# sudo yum -y install docker-ce-[VERSION]
1
2
3
systemctl enable docker.service
systemctl start docker.service
systemctl status docker.service

配置镜像加速器

Docker CE 镜像源站-阿里云

/etc/docker/daemon.json

1
2
3
{
"registry-mirrors": ["https://mqxz7mjm.mirror.aliyuncs.com"]
}
1
systemctl restart docker

安装docker-compose

下载 docker-compose releases

1
2
3
curl -L https://github.com/docker/compose/releases/download/1.23.2/docker-compose-`uname -s`-`uname -m` > /usr/local/bin/docker-compose

chmod +x /usr/local/bin/docker-compose

bash/zsh 补全命令

1
curl -L https://raw.githubusercontent.com/docker/compose/1.23.2/contrib/completion/bash/docker-compose > /etc/bash_completion.d/docker-compose

查看版本

1
docker-compose version

常用操作

下载一个标签下的所有镜像

1
docker image pull -a ubuntu

下载所有 ubuntu 镜像。

查看日志位置

1
docker inspect --format='{{.LogPath}}'

查看正在运行的容器是通过什么命令启动的

1
docker ps -a --no-trunc

收集性能数据

Collect Docker metrics with Prometheus | Docker Documentation

/etc/docker/daemon.json

1
2
3
4
{
"metrics-addr" : "127.0.0.1:9323",
"experimental" : true
}

macOS Docker-Deskop

Getting a Shell in the Docker for Mac Moby VM

启动终端,不太好使,字符容易乱。

1
screen ~/Library/Containers/com.docker.docker/Data/vms/0/tty

启动终端

1
docker run -it --rm --privileged --pid=host justincormack/nsenter1

参考

×

纯属好玩

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

文章目录
  1. 1. Docker
    1. 1.1. 安装
      1. 1.1.1. 配置镜像加速器
      2. 1.1.2. 安装docker-compose
    2. 1.2. 常用操作
    3. 1.3. 收集性能数据
    4. 1.4. macOS Docker-Deskop
    5. 1.5. 参考
,