### docker 安装步骤
#### 上传对应的软件包
docker-19.03.8.tgz
docker-compose-Linux-x86_64
#### 解压安装包进行安装
1.解压
```
tar -xvf docker-19.03.8.tgz
```
2.将解压下来的docker文件内容移动到/usr/bin/目录下
```
cp docker/* /usr/bin/
```
3.将docker注册为service
```
vim /etc/systemd/system/docker.service
```
将以下配置加到docker.service中并保存
```
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
```
#### 启动docker,并验证
添加文件权限,并启动docker服务
```
chmod +x /etc/systemd/system/docker.service
systemctl daemon-reload
systemctl start docker
```
设置开机自启docker
```
systemctl enable docker.service
```
验证查看docker状态
```
systemctl status docker
docker -v
```
### docker-compose 的安装
更改命名
```
mv docker-compose-Linux-x86_64 docker-compose
```
将文件复制到/usr/local/bin/目录下
```
cp docker-compose /usr/bin/docker-compose
```
为文件进行赋权限
```
chmod +x /usr/bin/docker-compose
```
验证是否安装成功
```
docker-compose version
```
验证结果如果出错
```
-bash: docker-compose: command not found
```
则需要将文件复制到/usr/bin/中,再进行赋权
```
cp docker-compose /usr/bin/
docker-compose version
```
### 使用docker进行安装镜像文件
此处以nginx为例
上传nginx.tar
```
[root@fastdfs software]# docker load -i nginx.tar
08249ce7456a: Loading layer [==================================================>] 83.9MB/83.9MB
d5b40e80384b: Loading layer [==================================================>] 62.01MB/62.01MB
b2f82de68e0d: Loading layer [==================================================>] 3.072kB/3.072kB
41451f050aa8: Loading layer [==================================================>] 4.096kB/4.096kB
44193d3f4ea2: Loading layer [==================================================>] 3.584kB/3.584kB
e7344f8a29a3: Loading layer [==================================================>] 7.168kB/7.168kB
Loaded image ID: sha256:55f4b40fe486a5b734b46bb7bf28f52fa31426bf23be068c8e7b19e58d9b8deb
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




