docker
在线
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| #containerd
yum install https://download.docker.com/linux/fedora/30/x86_64/stable/Packages/containerd.io-1.2.6-3.3.fc30.x86_64.rpm
#安装一些其他依赖
yum install -y yum-utils device-mapper-persistent-data lvm2
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
yum makecache
#安装docker-ce
dnf -y install docker-ce --nobest
#开启Docker服务并设置开机自启
systemctl start docker && sudo systemctl enable docker
#测试,如输出下图结果则安装成功
docker version
|
离线
下载20.10.13版本
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
| # 解压
tar -zxvf docker-20.10.13.tgz
# 复制
cp -rf docker/* /usr/bin/
# 创建docker.service
vi /usr/lib/systemd/system/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target docker.socket
[Service]
Type=notify
EnvironmentFile=-/run/flannel/docker
WorkingDirectory=/usr/local/bin
ExecStart=/usr/bin/dockerd \
-H tcp://0.0.0.0:4243 \
-H unix:///var/run/docker.sock \
--selinux-enabled=false \
--log-opt max-size=100m
ExecReload=/bin/kill -s HUP $MAINPID
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
TimeoutStartSec=0
Delegate=yes
KillMode=process
Restart=on-failure
[Install]
WantedBy=multi-user.target
# 重新加载
systemctl daemon-reload
# 开机启动
systemctl enable docker.service
# 查看版本
systemctl start docker
docker version
|
Docker-compose
在线
1
2
3
4
5
| sudo curl -L "https://github.com/docker/compose/releases/download/1.27.4/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
docker-compose --version
|
离线
下载
1
2
3
4
5
6
7
8
| # 复制到 /usr/local/bin
mv docker-compose-linux-x86_64 /usr/local/bin/docker-compose
# 设置可执行
chmod +x /usr/local/bin/docker-compose
# 创建软链
ln -sf /usr/local/bin/docker-compose /usr/bin/docker-compose
# 查看
docker-compose version
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
"registry-mirrors": [
"https://docker.m.daocloud.io",
"https://huecker.io",
"https://dockerhub.timeweb.cloud",
"https://noohub.ru"
]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
|
命令
1
2
3
4
5
6
7
8
9
10
| docker start xxx
docker stop xxx
docker rm xxx
# 查看进程
docker ps
# 进入容器
docker exec -ti xxx sh
# 查看日志
cd /usr/src/app && ./doctor
|
文章作者
lim
上次更新
2024-11-21
(1dac9ff)
许可协议
CC BY-NC-ND 4.0