Docker容器技术(二)

Docker容器技术

Docker熟识

Docker部署及配置

  • 安装Docker工具
cd /etc/yum.repos.d/
wget https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
sed -i 's#download.docer.com#mirrors.ustc.edu.cn/docker-ce#g' docker-ce.repo 
yum -y install docker-ce
systemctl enable --now docker.service
systemctl status docker # 检查docker是否成功启动
  • 启动第一个容器
docker container run -itd -p 8080:80 nginx:1.21
[root@seravACHu1bmB yum.repos.d]# docker container run -itd -name webserver -p 8080:80 nginx:1.21
Unable to find image 'nginx:1.21' locally
1.21: Pulling from library/nginx
42c077c10790: Pull complete 
62c70f376f6a: Pull complete 
915cc9bd79c2: Pull complete 
75a963e94de0: Pull complete 
7b1fab684d70: Pull complete 
db24d06d5af4: Pull complete 
Digest: sha256:2bcabc23b45489fb0885d69a06ba1d648aeda973fae7bb981bafbb884165e514
Status: Downloaded newer image for nginx:1.21
0272b5b53e6c824c817576bc4a0150dea21d4dc12a7cd79e80e87b88b36a94b2

  • 配置镜像加速
vim /etc/docker/daemon.json
{
        "registry-mirrors": ["https://registry.docker-cn.com"]
}

systemctl daemon-reload
systemctl restart docker.service

Docker基本指令

  • 查看docker版本信息: docker version
[root@seravACHu1bmB ~]# docker version
Client: Docker Engine - Community
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.17.11
 Git commit:        100c701
 Built:             Mon Jun  6 23:05:12 2022
 OS/Arch:           linux/amd64
 Context:           default
 Experimental:      true

Server: Docker Engine - Community
 Engine:
  Version:          20.10.17
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.11
  Git commit:       a89b842
  Built:            Mon Jun  6 23:03:33 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.6
  GitCommit:        10c12954828e7c7c9b6e0ea9b0c02b01407d3ae1
 runc:
  Version:          1.1.2
  GitCommit:        v1.1.2-0-ga916309
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

  • 基础资源查看
# 容器查看
docker container ls
[root@seravACHu1bmB ~]# docker container ls
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
# 镜像查看
docker image ls
[root@seravACHu1bmB ~]# docker image ls
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        1.21      0e901e68141f   2 months ago   142MB
# 网络查看
docker network ls
[root@seravACHu1bmB ~]# docker network ls
NETWORK ID     NAME      DRIVER    SCOPE
43d597988b9a   bridge    bridge    local
84fab538626c   host      host      local
aa73fa037ef8   none      null      local
# 数据卷
docker volume ls
[root@seravACHu1bmB ~]# docker volume ls
DRIVER    VOLUME NAME

  • 登录远程仓库,获取拉取镜像的权利
# 登录
docker login
[root@seravACHu1bmB ~]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: netdark
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-store

Login Succeeded
# 登出
docker logout
[root@seravACHu1bmB ~]# docker logout
Removing login credentials for https://index.docker.io/v1/

持续更新中… …

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值