日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Docker-核心篇(1)-CentOS7安装Docker社区版

發布時間:2024/3/13 编程问答 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Docker-核心篇(1)-CentOS7安装Docker社区版 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

  • 一、Docker安裝
  • 二、Docker卸載
  • 三、Docker鏡像
    • 3.1 官網鏡像倉庫
    • 3.2 阿里鏡像倉庫
  • 四、Docker 命令

一、Docker安裝

  • 參考文檔:https://docs.docker.com/engine/install/centos/
  • 卸載之前安裝Docker
  • sudo yum remove docker \docker-client \docker-client-latest \docker-common \docker-latest \docker-latest-logrotate \docker-logrotate \docker-engine
  • 安裝yum-utils包(提供yum-config-manager實用程序)并設置穩定存儲庫
  • yum install -y yum-utils yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
  • 安裝Docker Engine和containerd的最新版本,或者進入下一步安裝特定版本
  • yum install -y docker-ce docker-ce-cli containerd.io
  • 安裝完成后默認服務未啟動
    • systemctl status docker:查看docker服務狀態
  • [root@localhost vagrant]# systemctl status docker ● docker.service - Docker Application Container EngineLoaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)Active: inactive (dead)Docs: https://docs.docker.com
  • 啟動docker
    • systemctl start docker
  • [root@localhost vagrant]# systemctl start docker [root@localhost vagrant]# systemctl status docker ● docker.service - Docker Application Container EngineLoaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)Active: active (running) since Thu 2021-07-29 13:02:30 UTC; 2s agoDocs: https://docs.docker.comMain PID: 21062 (dockerd)Tasks: 8Memory: 56.2MCGroup: /system.slice/docker.service└─21062 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sockJul 29 13:02:30 localhost.localdomain dockerd[21062]: time="2021-07-29T13:02:30.611437237Z" level=info msg="schem...grpc Jul 29 13:02:30 localhost.localdomain dockerd[21062]: time="2021-07-29T13:02:30.611445537Z" level=info msg="ccRes...grpc Jul 29 13:02:30 localhost.localdomain dockerd[21062]: time="2021-07-29T13:02:30.611450657Z" level=info msg="Clien...grpc Jul 29 13:02:30 localhost.localdomain dockerd[21062]: time="2021-07-29T13:02:30.627090140Z" level=info msg="Loadi...rt." Jul 29 13:02:30 localhost.localdomain dockerd[21062]: time="2021-07-29T13:02:30.727488472Z" level=info msg="Defau...ess" Jul 29 13:02:30 localhost.localdomain dockerd[21062]: time="2021-07-29T13:02:30.760258611Z" level=info msg="Loadi...ne." Jul 29 13:02:30 localhost.localdomain dockerd[21062]: time="2021-07-29T13:02:30.793136460Z" level=info msg="Docke...10.7 Jul 29 13:02:30 localhost.localdomain dockerd[21062]: time="2021-07-29T13:02:30.793270992Z" level=info msg="Daemo...ion" Jul 29 13:02:30 localhost.localdomain systemd[1]: Started Docker Application Container Engine. Jul 29 13:02:30 localhost.localdomain dockerd[21062]: time="2021-07-29T13:02:30.819195488Z" level=info msg="API l...ock" Hint: Some lines were ellipsized, use -l to show in full.
  • 關閉docker
    • systemctl start docker
  • [root@localhost vagrant]# systemctl stop docker Warning: Stopping docker.service, but it can still be activated by:docker.socket [root@localhost vagrant]# systemctl status docker ● docker.service - Docker Application Container EngineLoaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)Active: inactive (dead) since Thu 2021-07-29 13:02:54 UTC; 13s agoDocs: https://docs.docker.comProcess: 21062 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=0/SUCCESS)Main PID: 21062 (code=exited, status=0/SUCCESS)Jul 29 13:02:30 localhost.localdomain dockerd[21062]: time="2021-07-29T13:02:30.727488472Z" level=info msg="Defau...ess" Jul 29 13:02:30 localhost.localdomain dockerd[21062]: time="2021-07-29T13:02:30.760258611Z" level=info msg="Loadi...ne." Jul 29 13:02:30 localhost.localdomain dockerd[21062]: time="2021-07-29T13:02:30.793136460Z" level=info msg="Docke...10.7 Jul 29 13:02:30 localhost.localdomain dockerd[21062]: time="2021-07-29T13:02:30.793270992Z" level=info msg="Daemo...ion" Jul 29 13:02:30 localhost.localdomain systemd[1]: Started Docker Application Container Engine. Jul 29 13:02:30 localhost.localdomain dockerd[21062]: time="2021-07-29T13:02:30.819195488Z" level=info msg="API l...ock" Jul 29 13:02:54 localhost.localdomain systemd[1]: Stopping Docker Application Container Engine... Jul 29 13:02:54 localhost.localdomain dockerd[21062]: time="2021-07-29T13:02:54.942850962Z" level=info msg="Proce...ed'" Jul 29 13:02:54 localhost.localdomain dockerd[21062]: time="2021-07-29T13:02:54.943694289Z" level=info msg="Daemo...ete" Jul 29 13:02:54 localhost.localdomain systemd[1]: Stopped Docker Application Container Engine. Hint: Some lines were ellipsized, use -l to show in full.
  • 開機自動啟動
    • systemctl enable docker
  • [root@localhost vagrant]# systemctl enable docker Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

    二、Docker卸載

  • 卸載Docker Engine、CLI和Containerd包
  • yum remove docker-ce docker-ce-cli containerd.io
  • 刪除所有鏡像、容器和卷,主機上的映像、容器、卷或自定義配置文件不會自動刪除
  • rm -rf /var/lib/docker rm -rf /var/lib/containerd
  • 必須手動刪除任何已編輯的配置文件
  • 三、Docker鏡像

    3.1 官網鏡像倉庫

  • 中央倉庫地址:https://hub.docker.com/
  • 通常選擇帶有Official Image為官方鏡像
  • 鏡像同樣也有很多版本,標識一個鏡像的名稱就是【官方鏡像名稱:tags】,例如MySQL 5.7版本就是 mysql:5.7
  • 各個鏡像的使用在詳情頁可以看到
  • 但是默認的鏡像倉庫在國外,國內下載速度不是很理想,可以使用鏡像加速器,例如阿里的鏡像加速
  • 3.2 阿里鏡像倉庫

  • 阿里的鏡像倉庫加速服務需要登錄網站后可以申請,所以鏡像加速與個人綁定
  • 鏡像地址:https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors
  • 通過修改daemon配置文件/etc/docker/daemon.json來使用加速器
  • mkdir -p /etc/docker tee /etc/docker/daemon.json <<-'EOF' {"registry-mirrors": ["https://tvwe72le.mirror.aliyuncs.com"] } EOF systemctl daemon-reload systemctl restart docker

    四、Docker 命令

    • 幫助命令
      • docker --help
    [root@localhost ~]# docker --helpUsage: docker COMMANDA self-sufficient runtime for containersOptions:--config string Location of client config files (default "/root/.docker")-D, --debug Enable debug mode--help Print usage-H, --host list Daemon socket(s) to connect to (default [])-l, --log-level string Set the logging level ("debug", "info", "warn", "error", "fatal") (default "info")--tls Use TLS; implied by --tlsverify--tlscacert string Trust certs signed only by this CA (default "/root/.docker/ca.pem")--tlscert string Path to TLS certificate file (default "/root/.docker/cert.pem")--tlskey string Path to TLS key file (default "/root/.docker/key.pem")--tlsverify Use TLS and verify the remote-v, --version Print version information and quitManagement Commands:container Manage containersimage Manage imagesnetwork Manage networksnode Manage Swarm nodesplugin Manage pluginssecret Manage Docker secretsservice Manage servicesstack Manage Docker stacksswarm Manage Swarmsystem Manage Dockervolume Manage volumesCommands:attach Attach to a running containerbuild Build an image from a Dockerfilecommit Create a new image from a container's changescp Copy files/folders between a container and the local filesystemcreate Create a new containerdiff Inspect changes on a container's filesystemevents Get real time events from the serverexec Run a command in a running containerexport Export a container's filesystem as a tar archivehistory Show the history of an imageimages List imagesimport Import the contents from a tarball to create a filesystem imageinfo Display system-wide informationinspect Return low-level information on Docker objectskill Kill one or more running containersload Load an image from a tar archive or STDINlogin Log in to a Docker registrylogout Log out from a Docker registrylogs Fetch the logs of a containerpause Pause all processes within one or more containersport List port mappings or a specific mapping for the containerps List containerspull Pull an image or a repository from a registrypush Push an image or a repository to a registryrename Rename a containerrestart Restart one or more containersrm Remove one or more containersrmi Remove one or more imagesrun Run a command in a new containersave Save one or more images to a tar archive (streamed to STDOUT by default)search Search the Docker Hub for imagesstart Start one or more stopped containersstats Display a live stream of container(s) resource usage statisticsstop Stop one or more running containerstag Create a tag TARGET_IMAGE that refers to SOURCE_IMAGEtop Display the running processes of a containerunpause Unpause all processes within one or more containersupdate Update configuration of one or more containersversion Show the Docker version informationwait Block until one or more containers stop, then print their exit codesRun 'docker COMMAND --help' for more information on a command.
  • 啟動命令:systemctl start docker
  • 關閉命令:systemctl stop docker
  • Docker 描述信息
    • docker info
  • # docker info Client:Context: defaultDebug Mode: falsePlugins: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: 0Images: 0Server Version: 20.10.7Storage 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: runc io.containerd.runc.v2 io.containerd.runtime.v1.linuxDefault Runtime: runcInit Binary: docker-initcontainerd version: 7eba5930496d9bbe375fdf71603e610ad737d2b2runc version: v1.0.0-0-g84113eeinit version: de40ad0Security Options:seccompProfile: defaultKernel Version: 3.10.0-1127.el7.x86_64Operating System: CentOS Linux 7 (Core)OSType: linuxArchitecture: x86_64CPUs: 1Total Memory: 487MiBName: localhost.localdomainID: H3NC:RHOD:UI64:ICUE:PP7J:OFPG:BMQR:OEHI:FFWL:EGR3:N7NR:Z5PWDocker Root Dir: /var/lib/dockerDebug Mode: falseRegistry: https://index.docker.io/v1/Labels:Experimental: falseInsecure Registries:127.0.0.0/8Registry Mirrors:https://tvwe72le.mirror.aliyuncs.com/Live Restore Enabled: falseWARNING: bridge-nf-call-iptables is disabled WARNING: bridge-nf-call-ip6tables is disabled

    總結

    以上是生活随笔為你收集整理的Docker-核心篇(1)-CentOS7安装Docker社区版的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。