卖摄影作品的网站,威海市建设局官方网站,ppt模板大全免费简约,石家庄模板建站行业解决方案文章目录 一、Docker二、离线安装Docker三、联网安装Docker3.1 下载YUM软件库文件3.2 安装epel-release3.3 安装yum-utils3.4 设置镜像仓库3.5 查看docker-ce所有版本3.6 安装Docker3.7 启动Docker3.8 查看Docker信息3.9 启动第一个容器 四、一些配置4.1 登录DockerHub4.2 镜像… 文章目录 一、Docker二、离线安装Docker三、联网安装Docker3.1 下载YUM软件库文件3.2 安装epel-release3.3 安装yum-utils3.4 设置镜像仓库3.5 查看docker-ce所有版本3.6 安装Docker3.7 启动Docker3.8 查看Docker信息3.9 启动第一个容器 四、一些配置4.1 登录DockerHub4.2 镜像加速器 一、Docker
Docker基于容器技术的轻量级虚拟化解决方案。 Docker是容器引擎把Linux的cgroup、namespace等容器底层技术进行封装抽象为用户提供了创建和管理容器的便捷界面包括命令行和API。
概念镜像Image容器Container仓库Repository
Docker镜像是一个静态模板不能直接修改可以通过封装生成Docker容器基于Docker镜像运行启动的应用或系统Docker仓库存放Docker镜像的地方常见分为公开仓库public和私有仓库private两种形式
二、离线安装Docker
Docker官网离线安装文档Install daemon and client binaries on Linux
安装步骤 1官网下载Docker安装包Index of linux/static/stable/x86_64/ 选取相应版本这边选了docker-20.10.9.tgz 2解压到/usr/bin/
[rootlocalhost ~]# tar -xzvf docker-20.10.9.tgz
docker/
docker/containerd-shim-runc-v2
docker/dockerd
docker/docker-proxy
docker/ctr
docker/docker
docker/runc
docker/containerd-shim
docker/docker-init
docker/containerd
[rootlocalhost ~]# ls
anaconda-ks.cfg docker docker-20.10.9.tgz
[rootlocalhost ~]# ls docker
containerd containerd-shim-runc-v2 docker docker-init runc
containerd-shim ctr dockerd docker-proxy
[rootlocalhost ~]# mv docker/* /usr/bin/3启动服务
[rootlocalhost ~]# dockerd
[1] 1673
[rootlocalhost ~]# INFO[2024-01-05T17:11:32.39869820008:00] Starting up
WARN[2024-01-05T17:11:32.40302150008:00] could not change group /var/run/docker.sock to docker: group docker not found
INFO[2024-01-05T17:11:32.40691990008:00] libcontainerd: started new containerd process pid1678
INFO[2024-01-05T17:11:32.40697940008:00] parsed scheme: unix modulegrpc
INFO[2024-01-05T17:11:32.40699170008:00] scheme unix not registered, fallback to default scheme modulegrpc
...
...[rootlocalhost ~]# ps -ef | grep docker | grep -v grep
root 1673 1625 0 17:11 pts/0 00:00:00 dockerd
root 1678 1673 0 17:11 ? 00:00:00 containerd --config /var/run/docker/containerd/containerd.toml --log-level info4验证
[rootlocalhost ~]# docker info
Client:Context: defaultDebug Mode: falseServer:Containers: 0Running: 0Paused: 0Stopped: 0Images: 0Server Version: 20.10.9Storage Driver: overlay2Backing Filesystem: xfsSupports d_type: trueNative Overlay Diff: trueuserxattr: falseLogging Driver: json-fileCgroup Driver: cgroupfsCgroup Version: 1Plugins:Volume: localNetwork: bridge host ipvlan macvlan null overlayLog: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslogSwarm: inactiveRuntimes: io.containerd.runc.v2 io.containerd.runtime.v1.linux runcDefault Runtime: runcInit Binary: docker-initcontainerd version: 5b46e404f6b9f661a205e28d59c982d3634148f8runc version: v1.0.2-0-g52b36a2dinit version: de40ad0Security Options:seccompProfile: defaultKernel Version: 3.10.0-862.el7.x86_64Operating System: CentOS Linux 7 (Core)OSType: linuxArchitecture: x86_64CPUs: 1Total Memory: 509.6MiBName: localhost.localdomainID: VM36:UOEO:67ST:Y2EU:RVE6:TC37:SZ6W:UNND:PF22:CWT2:FWYG:XZMADocker Root Dir: /var/lib/dockerDebug Mode: falseRegistry: https://index.docker.io/v1/Labels:Experimental: falseInsecure Registries:127.0.0.0/8Live Restore Enabled: falseProduct License: Community Engine5注册服务 kill掉前面手动启动的docker服务 在/usr/lib/systemd/system/目录下创建docker.service文件并添加内容
[rootlocalhost ~]# vi /usr/lib/systemd/system/docker.service
[Unit]
DescriptionDocker Application Container Engine
Documentationhttps://docs.docker.com
Afternetwork-online.target firewalld.service
Wantsnetwork-online.target[Service]
Typenotify
ExecStart/usr/bin/dockerd
ExecReload/bin/kill -s HUP $MAINPID
LimitNOFILEinfinity
LimitNPROCinfinity
LimitCOREinfinity
TimeoutStartSec0
Delegateyes
KillModeprocess
Restarton-failure
StartLimitBurst3
StartLimitInterval60s[Install]
WantedBymulti-user.target重新加载
[rootlocalhost ~]# systemctl daemon-reload服务的相关操作
[rootlocalhost ~]# systemctl start docker
[rootlocalhost ~]# systemctl stop docker
[rootlocalhost ~]# systemctl status docker
[rootlocalhost ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.此时就可通过systemctl来启停Docker服务了。
三、联网安装Docker
3.1 下载YUM软件库文件
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo3.2 安装epel-release
yum install epel-release -y3.3 安装yum-utils
在配置国内镜像仓库时会遇到如下报错此时就需要安装yum-utils。
[rootserver ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
-bash: yum-config-manager: command not foundyum install yum-utils -y3.4 设置镜像仓库
设置镜像仓库这边使用国内的阿里云镜像仓库
[rootserver ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
Loaded plugins: fastestmirror
adding repo from: http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
grabbing file http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo to /etc/yum.repos.d/docker-ce.repo
repo saved to /etc/yum.repos.d/docker-ce.repo3.5 查看docker-ce所有版本
[rootserver ~]# yum list docker-ce --show-duplicates
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* epel: mirrors.nju.edu.cn
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
docker-ce-stable | 3.5 kB 00:00:00
(1/2): docker-ce-stable/7/x86_64/updateinfo | 55 B 00:00:00
(2/2): docker-ce-stable/7/x86_64/primary_db | 62 kB 00:00:00
Available Packages
docker-ce.x86_64 17.03.0.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.2.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.03.3.ce-1.el7 docker-ce-stable
docker-ce.x86_64 17.06.0.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.1.ce-1.el7.centos docker-ce-stable
docker-ce.x86_64 17.06.2.ce-1.el7.centos docker-ce-stable3.6 安装Docker
[rootserver ~]# yum install docker-ce3.7 启动Docker
[rootserver ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[rootserver ~]# systemctl start docker
[rootserver ~]#3.8 查看Docker信息
[rootserver ~]# docker info
Client:
Context: default
Debug Mode: false
Plugins:app: Docker App (Docker Inc., v0.9.1-beta3)buildx: Build with BuildKit (Docker Inc., v0.5.1-docker)scan: Docker Scan (Docker Inc., v0.8.0)Server:
Containers: 0Running: 0Paused: 0Stopped: 0
Images: 0
Server Version: 20.10.7
Storage Driver: overlay2Backing Filesystem: xfsSupports d_type: trueNative Overlay Diff: trueuserxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 1
...# 安装完成后docker自动创建了docker组为安全起见将当前登录用户追加入到该组中
[rootserver~ ]# id root
uid0(root) gid0(root) groups0(root)
[rootserver~ ]# usermod -aG docker $USER
[rootserver~ ]# id root
uid0(root) gid0(root) groups0(root),993(docker)3.9 启动第一个容器
[rootserver ~]# docker run hello-world
Unable to find image hello-world:latest locally
latest: Pulling from library/hello-world
c1ec31eb5944: Pull complete
Digest: sha256:ac69084025c660510933cca701f615283cdbb3aa0963188770b54c31c8962493
Status: Downloaded newer image for hello-world:latestHello from Docker!
This message shows that your installation appears to be working correctly.To generate this message, Docker took the following steps:1. The Docker client contacted the Docker daemon.2. The Docker daemon pulled the hello-world image from the Docker Hub.(amd64)3. The Docker daemon created a new container from that image which runs theexecutable that produces the output you are currently reading.4. The Docker daemon streamed that output to the Docker client, which sent itto your terminal.To try something more ambitious, you can run an Ubuntu container with:$ docker run -it ubuntu bashShare images, automate workflows, and more with a free Docker ID:https://hub.docker.com/For more examples and ideas, visit:https://docs.docker.com/get-started/四、一些配置
4.1 登录DockerHub
访问https://hub.docker.com/先注册个账号 之后在本地端登录
[rootserver ~]# docker login docker.io
Login with your Docker ID to push and pull images from Docker Hub. If you dont have a Docker ID, head over to https://hub.docker.com to create one.
Username: asdfv1929
Password:
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-storeLogin Succeeded
[rootserver ~]#登录完成后此时便可拉取Docker Hub上自己仓库里的镜像。
4.2 镜像加速器
[rootserver ~]# vi /etc/docker/daemon.json
{registry-mirrors: [http://hub-mirror.c.163.com,https://docker.mirrors.ustc.edu.cn]
}[rootserver ~]# systemctl daemon-reload
[rootserver ~]# systemctl restart dockerustc的链接已失效