Linux安装Docker(图文解说详细版)

简介: Linux安装Docker(图文解说详细版)

第一步,下载docker


下载地址:

https://download.docker.com/linux/static/stable/x86_64/

这次的演示我们使用docker-18.06.3-ce.tgz 这个版本

e709b935316f46bbb4ef940c2537fcd8.png

第二步,上传到云服务器上面


82a19056867c429daadbd5a846c739bf.png


7eb64b47b9f147c7a8eda66c1ca56ba0.png

使用rz命令上传或者fltp工具进行上传

第三步,解压文件



d94be1fdfd794222bdd8517bed84c05e.png


第四步,将解压出来的docker文件复制到 /usr/bin/ 目录下

这么做的目的是将docker交给linux自己去管理,类似spring中的ioc(猜测,非正经知识)

cp docker/* /usr/bin/


ec7a45999d1d440db73c46d077add7e9.png


第五步, 在/etc/systemd/system/目录下新增docker.service文件,内容如下,这样可以将docker注册为service服务

a080d927dac64475b1505793ce8902bc.png

[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 --selinux-enabled=false --insecure-registry=127.0.0.1
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


7021f5ea0e34460585674e89283c2d41.png5891f9a0edf14dd0ba264c81c4a5c41a.png


第六步, 启动docker

systemctl start docker


5d04f82846bf46619cc988df671d96b7.png


第七步,查看docker状态

systemctl status docker


a0884ebd2390461dba74b28e62df1ea3.png

active (running)

正在运行中!!

这样的话就是未运行

4cd02f9fd7a3422cbaf8f256a9a12655.png

拓展:


停止docker systemctl stop docker

设置开机启动systemctl enable docker.service

重新加载配置文件(每次有修改docker.service文件时都要重新加载下)

systemctl daemon-reload


systemctl 提供了一组子命令来管理单个的 unit,其命令格式为:

systemctl [command] [unit]


command 主要有:


start:立刻启动后面接的 unit。


stop:立刻关闭后面接的 unit。


restart:立刻关闭后启动后面接的 unit,亦即执行 stop 再 start 的意思。


reload:不关闭 unit 的情况下,重新载入配置文件,让设置生效。


enable:设置下次开机时,后面接的 unit 会被启动。


disable:设置下次开机时,后面接的 unit 不会被启动。


status:目前后面接的这个 unit 的状态,会列出有没有正在执行、开机时是否启动等信息。


is-active:目前有没有正在运行中。


is-enabled:开机时有没有默认要启用这个 unit。


kill :不要被 kill 这个名字吓着了,它其实是向运行 unit 的进程发送信号。


show:列出 unit 的配置。


mask:注销 unit,注销后你就无法启动这个 unit 了。


unmask:取消对 unit 的注销。


相关文章
|
2天前
|
持续交付 开发工具 git
阿里云云效产品使用问题之在云效代码域中gitlab使用docker安装的,迁移时遇到“获取企业信息失败”,是什么原因
云效作为一款全面覆盖研发全生命周期管理的云端效能平台,致力于帮助企业实现高效协同、敏捷研发和持续交付。本合集收集整理了用户在使用云效过程中遇到的常见问题,问题涉及项目创建与管理、需求规划与迭代、代码托管与版本控制、自动化测试、持续集成与发布等方面。
|
1天前
|
Unix Docker 容器
使用docker 启动naocs 报错出现:standard_init_linux.go:241: exec user process caused "exec format error"
```markdown Error in Docker container startup: "standard_init_linux.go:241: exec user process caused \"exec format error\"". Occurred at 2024-06-29 09:26:19.910, followed by a failed hook with a syslog delivery error at 09:27:20.193. Seeking solutions from experts. ```
|
2天前
|
NoSQL Java Linux
linux 安装 neo4j简介
Neo4j是高性能NoSQL图形数据库,利用图结构存储数据。推荐使用JDK 11配合Neo4j 3.x版本。下载3.5.9版,通过`curl`命令在Linux上获取tar.gz文件,然后解压。配置`neo4j.conf`,调整内存设置,开启远程访问。执行`./bin/neo4j start`启动,通过`http://服务器IP:7474`访问,默认凭据是username: neo4j, password: neo4j,登录后应更改密码。
10 0
|
2天前
|
Oracle Java 关系型数据库
在Linux环境下采用压缩包方式安装JDK 13
在Linux环境下采用压缩包方式安装JDK 13
|
2天前
|
Linux 数据库
Linux安装达梦数据库达梦数据
Linux安装达梦数据库达梦数据
5 0
|
3天前
|
Linux Shell Python
linux服务器python2升级安装python3.7环境
linux服务器python2升级安装python3.7环境
8 0
|
3天前
|
应用服务中间件 nginx Docker
Docker安装与管理Nginx
Docker安装与管理Nginx
25 0
|
3天前
|
缓存 Linux Docker
CentOS 7 下安装 Docker 及配置阿里云加速服务
CentOS 7 下安装 Docker 及配置阿里云加速服务
45 0
|
3天前
|
Linux C++
在Linux上安装CLion
在Linux上安装CLion
10 0
|
3天前
|
Java 编译器 Linux
程序技术好文:详解Linux安装GCC方法
程序技术好文:详解Linux安装GCC方法