Docker------基础命令

  • 一、安装Docker
    • 1.1 安装依赖包
    • 1.2 设置阿里云镜像源
    • 1.3 安装Docker-CE
    • 1.4 镜像加速
    • 1.5 网络优化
  • 二、查看docker版本信息
  • 三、查找指定镜像
  • 四、查看镜像/下载镜像
  • 五、删除docker镜像
  • 六、添加新标签
  • 七、镜像备份
  • 八、上传镜像
    • 8.1 登录
    • 8.2 上传
  • 九、容器操作
    • 9.1 创建容器
    • 9.2 查看容器的状态信息
    • 9.3 启动容器
    • 9.4 启动执行命令查看系统根目录
    • 9.5 终止运行
    • 9.6 删除容器
    • 9.7 进入/退出容器
    • 9.8 容器导出
    • 9.9 容器导入
  • 十、私有库创建
  • 十一、docker容器卷
  • 十二、数据卷容器
  • 十三、端口映射
  • 十四、容器互联(使用centos镜像)
  • 十五、编写脚本的流程

一、安装Docker

1.1 安装依赖包

iptables -F
setenforce 0
yum install -y yum-utils device-mapper-persistent-data lvm2         #在线源安装#yum-utils提供了yum-config-manager
#Device Mapper 存储驱动程序需要device-mapper-persistent-data和lvm2
#Device Mapper是Linux内核中支持逻辑卷管理的通用设备映射机制,它为实现用于存储资源管理的块设备驱动提供了一个高度模块化的内核架构。

1.2 设置阿里云镜像源

yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

1.3 安装Docker-CE

yum install -y docker-ce
vim /etc/selinux/config
SELINUX=disabled
[root@localhost etc]# cd /etc/docker
-bash: cd: /etc/docker: 没有那个文件或目录
[root@localhost etc]# systemctl start docker.service
[root@localhost etc]# systemctl enable docker.service
[root@localhost etc]# cd /etc/docker/
[root@localhost docker]# ls
key.json
[root@localhost docker]# vim key.json      #对接docker共有仓库的密钥
#key.json中的数据格式是以键值对key:value的json格式
{"crv":"P-256","d":"rQw9EAqWUorGAIz6Kp0MpXIjd2EE1L7ugpN7WYllEL4","kid":"2LIM:GQWG:XXHM:LW4K:CCYM:MAJJ:BAG7:Q2NP:RN7A:EBJX:FGVJ:YT46","kty":"EC","x":"cLZ5e0UHgJ63_00sqSP7G9xmG-EJC2tuqO-wVRoJTlY","y":"KlA8UesRJBWpzKvM7Cx1IMHzvJgGfj7vi9KAQ-r1UbA"}[root@localhost docker]# ifconfig      #查看网卡多出一个docker0网卡
docker0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500inet 172.17.0.1  netmask 255.255.0.0  broadcast 172.17.255.255ether 02:42:d3:aa:41:77  txqueuelen 0  (Ethernet)RX packets 0  bytes 0 (0.0 B)RX errors 0  dropped 0  overruns 0  frame 0TX packets 0  bytes 0 (0.0 B)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

1.4 镜像加速

tee /etc/docker/daemon.json <<-'EOF'
{"registry-mirrors": ["https://xxxxxxxx.mirror.aliyuncs.com"]
}
EOF
systemctl daemon-reload
systemctl restart docker

1.5 网络优化

vim /etc/sysctl.conf
net.ipv4.ip_forward=1sysctl -p
systemctl restart network
systemctl restart docker

二、查看docker版本信息

docker version               #查看docker版本信息
Client: Docker Engine - CommunityVersion:           20.10.5         #docker版本API version:       1.41            #API版本Go version:        go1.13.15      #go语言版本,由go开发Git commit:        55c4c88          Built:             Tue Mar  2 20:33:55 2021OS/Arch:           linux/amd64Context:           defaultExperimental:      trueServer: Docker Engine - CommunityEngine:Version:          20.10.5API version:      1.41 (minimum version 1.12)Go version:       go1.13.15Git commit:       363e9a8Built:            Tue Mar  2 20:32:17 2021OS/Arch:          linux/amd64Experimental:     falsecontainerd:Version:          1.4.4GitCommit:        05f951a3781f4f2c1911b05e61c160e9c30eaa8erunc:Version:          1.0.0-rc93GitCommit:        12644e614e25b05da6fd08a38ffa0cfe1903fdecdocker-init:Version:          0.19.0GitCommit:        de40ad0

三、查找指定镜像

docker search nginx              #查找指定镜像
docker search nginx              #查找指定镜像
NAME                               DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
#镜像名称                          描述                                              星级(好评度)
nginx                              Official build of Nginx.                        14607     [OK]
jwilder/nginx-proxy                Automated Nginx reverse proxy for docker con…   1988                 [OK]            #jwilder/nginx-proxy 仓库名/镜像名
richarvey/nginx-php-fpm            Container running Nginx + PHP-FPM capable of…   811                  [OK]
jc21/nginx-proxy-manager           Docker container for managing Nginx proxy ho…   163
linuxserver/nginx                  An Nginx container, brought to you by LinuxS…   142
tiangolo/nginx-rtmp                Docker image with Nginx using the nginx-rtmp…   119                  [OK]
jlesage/nginx-proxy-manager        Docker container for Nginx Proxy Manager        97                   [OK]
bitnami/nginx                      Bitnami nginx Docker Image                      95                   [OK]
alfg/nginx-rtmp                    NGINX, nginx-rtmp-module and FFmpeg from sou…   89                   [OK]
jasonrivers/nginx-rtmp             Docker images to host RTMP streams using NGI…   88                   [OK]
nginxdemos/hello                   NGINX webserver that serves a simple page co…   67                   [OK]
privatebin/nginx-fpm-alpine        PrivateBin running on an Nginx, php-fpm & Al…   50                   [OK]
nginx/nginx-ingress                NGINX Ingress Controller for Kubernetes         49
nginxinc/nginx-unprivileged        Unprivileged NGINX Dockerfiles                  32
schmunk42/nginx-redirect           A very simple container to redirect HTTP tra…   19                   [OK]
staticfloat/nginx-certbot          Opinionated setup for automatic TLS certs lo…   19                   [OK]
nginx/nginx-prometheus-exporter    NGINX Prometheus Exporter                       16
centos/nginx-112-centos7           Platform for running nginx 1.12 or building …   15
centos/nginx-18-centos7            Platform for running nginx 1.8 or building n…   13
raulr/nginx-wordpress              Nginx front-end for the official wordpress:f…   13                   [OK]
flashspys/nginx-static             Super Lightweight Nginx Image                   9                    [OK]
bitnami/nginx-ingress-controller   Bitnami Docker Image for NGINX Ingress Contr…   8                    [OK]
mailu/nginx                        Mailu nginx frontend                            8                    [OK]
ansibleplaybookbundle/nginx-apb    An APB to deploy NGINX                          2                    [OK]
wodby/nginx                        Generic nginx                                   1                    [OK]

四、查看镜像/下载镜像

docker images 仓库名称:标签                #查看下载镜像信息
docker inspect 镜像ID                 #获取镜像信息
docker pull 仓库名称:标签                 #获取/下载镜像 ,AUFS(联合文件系统)分层下载
#下载后存放在/var/lib/docker中
/var/lib/docker/image/overlay/repositories.json         #下载文件信息
[root@localhost docker]# docker images              #查看镜像
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
[root@localhost docker]# docker pull nginx         #下载nginx镜像,分层下载(分布式)
Using default tag: latest
latest: Pulling from library/nginx
a076a628af6f: Pull complete
0732ab25fa22: Pull complete
d7f36f6fe38f: Pull complete
f72584a26f32: Pull complete
7125e4df9063: Pull complete
Digest: sha256:10b8cc432d56da8b61b070f4c7d2543a9ed17c2b23010b43af434fd40e2ca4aa
Status: Downloaded newer image for nginx:latest
docker.io/library/nginx:latest
[root@localhost docker]# docker images             #查看镜像,已经下载
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        latest    f6d0b4767a6c   2 months ago   133MB

五、删除docker镜像

docker rmi 仓库名称:标签
docker rmi 镜像ID
docker rmi nginx             #以镜像名称删除
docker rmi f6d0b4767a6c         #以镜像ID删除

六、添加新标签

docker tag 名称:标签 新名称:新标签
[root@localhost docker]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        latest    f6d0b4767a6c   2 months ago   133MB
[root@localhost docker]# docker tag nginx:latest nginx:test        #添加新标签
[root@localhost docker]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        latest    f6d0b4767a6c   2 months ago   133MB
nginx        test      f6d0b4767a6c   2 months ago   133MB      #新标签镜像
#此时不能使用镜像ID删除镜像,可以通过标签删除任一镜像

七、镜像备份

cd /opt/         #存放在此目录中
docker save -o xyw_nginx nginx:latest           #镜像备份,文件名为xyw_nginx
docker load < xyw_nginx          #载入镜像
docker --input xyw_nginx        #载入镜像
[root@localhost docker]# docker images                              #此时镜像存在
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        latest    f6d0b4767a6c   2 months ago   133MB
nginx        test      f6d0b4767a6c   2 months ago   133MB
[root@localhost docker]# cd /opt/
[root@localhost opt]# docker save -o xyw_nginx nginx:latest            #镜像备份
[root@localhost opt]# ls
containerd  rh  xyw_nginx
[root@localhost opt]# ll -h
总用量 131M
drwx--x--x. 4 root root   28 3月  22 14:45 containerd
drwxr-xr-x. 2 root root    6 3月  26 2015 rh
-rw-------. 1 root root 131M 3月  22 15:56 xyw_nginx         #备份的镜像文件
[root@localhost opt]# docker rmi nginx:latest                  #删除原有镜像
Untagged: nginx:latest
[root@localhost opt]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        test      f6d0b4767a6c   2 months ago   133MB
[root@localhost opt]# docker rmi f6d0b4767a6c                  #继续删除
Untagged: nginx:test
Untagged: nginx@sha256:10b8cc432d56da8b61b070f4c7d2543a9ed17c2b23010b43af434fd40e2ca4aa
Deleted: sha256:f6d0b4767a6c466c178bf718f99bea0d3742b26679081e52dbf8e0c7c4c42d74
Deleted: sha256:4dfe71c4470c5920135f00af483556b09911b72547113512d36dc29bfc5f7445
Deleted: sha256:3c90a0917c79b758d74b7040f62d17a7680cd14077f734330b1994a2985283b8
Deleted: sha256:a1c538085c6f891424160d8db120ea093d4dda393e94cd4713e3fff3c82299b5
Deleted: sha256:a3ee2510dcf02c980d7aff635909612006fd1662084d6225e52e769b984abeb5
Deleted: sha256:cb42413394c4059335228c137fe884ff3ab8946a014014309676c25e3ac86864
[root@localhost opt]# docker images                                #此时已没有镜像
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
[root@localhost opt]# docker load < xyw_nginx                   #恢复镜像
cb42413394c4: Loading layer  72.51MB/72.51MB
1c91bf69a08b: Loading layer   64.6MB/64.6MB
56bc37de0858: Loading layer  3.072kB/3.072kB
3e5288f7a70f: Loading layer  4.096kB/4.096kB
85fcec7ef3ef: Loading layer  3.584kB/3.584kB
Loaded image: nginx:latest
[root@localhost opt]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        latest    f6d0b4767a6c   2 months ago   133MB

八、上传镜像

8.1 登录

docker login
Username: docker
password:
Email:xxx@xxx.com

8.2 上传

docker push xyw/nginx:web

九、容器操作

9.1 创建容器

docker create -it nginx:latest /bin/bash         #创建容器
-i:让容器的标准输入保持打开
-t:唐docker分配一个伪终端
/bin/bash:运行环境

9.2 查看容器的状态信息

docker ps                #查看运行中容器的状态信息
docker ps -a            #查看所有容器的状态信息

9.3 启动容器

docker start 868b3950cca5            #后面加容器的序列号

9.4 启动执行命令查看系统根目录

docker run centos:7 /bin/bash -c ls /
-d:表示开启守护进程daemon,后台运行
-c:表示继续执行后面的命令,ls / 查看系统根目录
docker run -d centos:7 /bin/bash -c "while reue;do echo hello;done"       #死循环
#常见的坑,docker,容器使用后台运行,必须要有一个前台进程,docker发现没有应用就会自动停止,发现自己没提供服务就会自动停止,这就是为什么要创死循环的原因
# -it  可以保持up状态[root@localhost ~]# docker run -d centos:7 /bin/bash
a2e79a14833ca866483deb1438c17f9e4c21dd254bb08568a1c69116f82c3625
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE      COMMAND                  CREATED         STATUS                     PORTS     NAMES
a2e79a14833c   centos:7   "/bin/bash"              7 seconds ago   Exited (0) 5 seconds ago                    crazy_khorana          #即使启动了,因为没有服务运行,还是终止了
fe61b1e97eda   centos:7   "/bin/bash -c 'while…"   3 hours ago     Exited (137) 2 hours ago             inspiring_jennings
e1d8e30f7902   centos:7   "/bin/bash -c 'while…"   4 hours ago     Exited (137) 3 hours ago             frosty_elbakyan[root@localhost ~]# docker run -itd nginx:latest /bin/bash
4e0245a200ffb43b45b320f9b413616e7d14e8b5e304690e1d6622528a248fa2
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS     NAMES
4e0245a200ff   nginx:latest   "/docker-entrypoint.…"   2 seconds ago   Up 2 seconds   80/tcp    confident_cohen[root@localhost ~]# docker run -itd centos:7 /bin/bash
f3754aa308bd1cb16c0d25bec57763729cb8067cc8890d4b17faa6f20aa4e36b
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS          PORTS     NAMES
f3754aa308bd   centos:7       "/bin/bash"              2 seconds ago    Up 1 second               busy_moore
4e0245a200ff   nginx:latest   "/docker-entrypoint.…"   30 seconds ago   Up 29 seconds   80/tcp    confident_cohen
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        latest    f6d0b4767a6c   2 months ago   133MB
[root@localhost ~]# docker ps -a                                       #查看所有容器的状态信息
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES  #有镜像但没有容器
[root@localhost ~]# docker create -it nginx:latest /bin/bash           #创建容器
868b3950cca56f28a640926ee224c151f7ad58e4760d89ce29e4caba0365a6b9        #创建容器的序列号[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS    PORTS     NAMES
868b3950cca5   nginx:latest   "/docker-entrypoint.…"   10 seconds ago   Created             upbeat_swartz                         #状态是创建状态,COMMAND是分配的终端
[root@localhost ~]# docker start 868b3950cca5                          #启动容器
868b3950cca5[root@localhost ~]# docker ps -a                                       #查看所有容器,docker ps 表示查看运行状态的容器
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS     NAMES
868b3950cca5   nginx:latest   "/docker-entrypoint.…"   2 minutes ago   Up 3 seconds   80/tcp    upbeat_swartz #开启后会有端口号
[root@localhost ~]# docker run centos:7 /bin/bash -c ls /              #-c表示运行后面的命令
Unable to find image 'centos:7' locally
7: Pulling from library/centos
2d473b07cdd5: Pull complete
Digest: sha256:0f4ec88e21daf75124b8a9e5ca03c37a5e937e0e108a255d890492430789b60e
Status: Downloaded newer image for centos:7
anaconda-post.log                                                       #这里是ls的结果
bin
dev
etc
home
lib
lib64
media
mnt
opt
proc
root
run
sbin
srv
sys
tmp
usr
var[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        latest    f6d0b4767a6c   2 months ago   133MB
centos       7         8652b9f0cb4c   4 months ago   204MB              #下载了centos7的镜像
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS                     PORTS     NAMES
b1cde108db4b   centos:7       "/bin/bash -c ls /"      4 minutes ago    Exited (0) 4 minutes ago             sweet_wozniak                            #容器已创建完成
868b3950cca5   nginx:latest   "/docker-entrypoint.…"   35 minutes ago   Up 33 minutes              80/tcp    upbeat_swartz[root@localhost ~]# docker run -d centos:7 /bin/bash
2ca7c5a8ab5385da21e72609e42508361f70fd89bf4697e1efa45282f62b0e8a
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED             STATUS                      PORTS     NAMES
2ca7c5a8ab53   centos:7       "/bin/bash"              7 seconds ago       Exited (0) 6 seconds ago              tender_curran
b1cde108db4b   centos:7       "/bin/bash -c ls /"      41 minutes ago      Exited (0) 41 minutes ago             sweet_wozniak
868b3950cca5   nginx:latest   "/docker-entrypoint.…"   About an hour ago   Up About an hour            80/tcp    upbeat_swartz
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        latest    f6d0b4767a6c   2 months ago   133MB
centos       7         8652b9f0cb4c   4 months ago   204MB[root@localhost ~]# docker run -d centos:7 /bin/bash -c "while true;do echo hello;done"
e1d8e30f79025228bade8faab7f7d9faaf6d1af5ba88b1490834fe350f818f95
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED             STATUS                      PORTS     NAMES
e1d8e30f7902   centos:7       "/bin/bash -c 'while…"   4 seconds ago       Up 2 seconds                          frosty_elbakyan
2ca7c5a8ab53   centos:7       "/bin/bash"              2 minutes ago       Exited (0) 2 minutes ago              tender_curran
b1cde108db4b   centos:7       "/bin/bash -c ls /"      43 minutes ago      Exited (0) 43 minutes ago             sweet_wozniak
868b3950cca5   nginx:latest   "/docker-entrypoint.…"   About an hour ago   Up About an hour            80/tcp    upbeat_swartz
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        latest    f6d0b4767a6c   2 months ago   133MB
centos       7         8652b9f0cb4c   4 months ago   204MB
[root@localhost ~]# top
top - 11:00:30 up  4:09,  5 users,  load average: 1.53, 0.40, 0.17
Tasks: 202 total,   4 running, 197 sleeping,   1 stopped,   0 zombie
%Cpu(s): 63.1 us, 34.2 sy,  0.0 ni,  2.5 id,  0.0 wa,  0.0 hi,  0.2 si,  0.0 st
KiB Mem :  2031912 total,    71700 free,   864396 used,  1095816 buff/cache
KiB Swap:  4192252 total,  4091376 free,   100876 used.   865444 avail Mem PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                           50350 root      20   0   11692   1052    868 R  99.0  0.1   0:27.16 bash                              43455 root      20   0  598100  55104   4884 S  76.4  2.7   0:39.00 dockerd                           50328 root      20   0  112980   3408   2172 S  15.6  0.2   0:04.31 containerd-shim                   46377 root      20   0       0      0      0 R   1.7  0.0   0:02.03 kworker/u256:0                    [root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED              STATUS                          PORTS     NAMES
e1d8e30f7902   centos:7       "/bin/bash -c 'while…"   52 seconds ago       Up 50 seconds                             frosty_elbakyan
2ca7c5a8ab53   centos:7       "/bin/bash"              2 minutes ago        Exited (0) 2 minutes ago                  tender_curran
b1cde108db4b   centos:7       "/bin/bash -c ls /"      44 minutes ago       Exited (0) 44 minutes ago                 sweet_wozniak
868b3950cca5   nginx:latest   "/docker-entrypoint.…"   About an hour ago    Up About an hour                80/tcp    upbeat_swartz

9.5 终止运行

docker stop 868b3950cca5
[root@localhost ~]# docker stop 868b3950cca5
868b3950cca5
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED              STATUS                        PORTS     NAMES
e1d8e30f7902   centos:7       "/bin/bash -c 'while…"   About a minute ago   Up About a minute                       frosty_elbakyan
2ca7c5a8ab53   centos:7       "/bin/bash"              3 minutes ago        Exited (0) 3 minutes ago                tender_curran
b1cde108db4b   centos:7       "/bin/bash -c ls /"      45 minutes ago       Exited (0) 45 minutes ago               sweet_wozniak
868b3950cca5   nginx:latest   "/docker-entrypoint.…"   About an hour ago    Exited (137) 11 seconds ago             upbeat_swartz
# Exited(0)、 Exited(137):0为正常退出;不为0则异常退出。

9.6 删除容器

docker rm cb9c9eb25ffb
docker ps -a | awk '{print "docker rm "$1}' | bash          #删除非运行状态容器
docker rm `docker ps -aq`                                 #删除非运行状态容器
docker rm -f `docker ps -aq`                              #删除所有容器
[root@localhost ~]# docker ps -a | awk '{print "docker rm "$1}' | bash          #docker rm `docker ps -aq` 也可以删除非运行容器    -f强制删除所有容器
Error: No such container: CONTAINER
Error response from daemon: You cannot remove a running container e1d8e30f79025228bade8faab7f7d9faaf6d1af5ba88b1490834fe350f818f95. Stop the container before attempting removal or force remove
cb9c9eb25ffb
2ca7c5a8ab53
b1cde108db4b
868b3950cca5
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE      COMMAND                  CREATED         STATUS         PORTS     NAMES
e1d8e30f7902   centos:7   "/bin/bash -c 'while…"   3 minutes ago   Up 3 minutes             frosty_elbakyan
[root@localhost ~]# top
top - 11:03:59 up  4:13,  5 users,  load average: 4.95, 2.65, 1.11
Tasks: 199 total,   2 running, 196 sleeping,   1 stopped,   0 zombie
%Cpu(s): 66.1 us, 30.9 sy,  0.0 ni,  3.0 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  2031912 total,    74032 free,   358112 used,  1599768 buff/cache
KiB Swap:  4192252 total,  3596084 free,   596168 used.  1388780 avail Mem PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                           50350 root      20   0   11692    340    156 R 100.0  0.0   3:54.26 bash                              43455 root      20   0  598100  36620   3712 S  76.4  1.8   3:17.21 dockerd                           50328 root      20   0  113108   1904    644 S  16.3  0.1   0:37.05 containerd-shim
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE      COMMAND                  CREATED              STATUS                     PORTS     NAMES
a2e79a14833c   centos:7   "/bin/bash"              About a minute ago   Exited (0) 1 second ago              crazy_khorana
fe61b1e97eda   centos:7   "/bin/bash -c 'while…"   3 hours ago          Exited (137) 2 hours ago             inspiring_jennings
e1d8e30f7902   centos:7   "/bin/bash -c 'while…"   4 hours ago          Exited (137) 3 hours ago             frosty_elbakyan
[root@localhost ~]# docker rm
crazy_khorana       frosty_elbakyan     inspiring_jennings
[root@localhost ~]# docker rm `docker ps -aq`                                    #删除非运行状态容器
a2e79a14833c
fe61b1e97eda
e1d8e30f7902
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

9.7 进入/退出容器

[root@localhost ~]# docker exec -it f3754aa308bd /bin/bash          #进入容器时,容器必须是up状态
[root@f3754aa308bd /]# ls
anaconda-post.log  dev  home  lib64  mnt  proc  run   srv  tmp  var
bin                etc  lib   media  opt  root  sbin  sys  usr
[root@f3754aa308bd /]# ifconfig
bash: ifconfig: command not found
[root@f3754aa308bd /]# yum -y install net-tools
[root@f3754aa308bd /]# ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500inet 172.17.0.3  netmask 255.255.0.0  broadcast 172.17.255.255         #IP地址为172.17.0.3,局域网ether 02:42:ac:11:00:03  txqueuelen 0  (Ethernet)RX packets 9154  bytes 14341841 (13.6 MiB)RX errors 0  dropped 0  overruns 0  frame 0TX packets 5018  bytes 274305 (267.8 KiB)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536inet 127.0.0.1  netmask 255.0.0.0loop  txqueuelen 1  (Local Loopback)RX packets 0  bytes 0 (0.0 B)RX errors 0  dropped 0  overruns 0  frame 0TX packets 0  bytes 0 (0.0 B)TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
[root@f3754aa308bd /]# exit
exit
[root@localhost ~]#

9.8 容器导出

[root@localhost ~]# docker export f3754aa308bd > /opt/cent
[root@localhost ~]# cd /opt/
[root@localhost opt]# ls
cent  containerd  rh  xyw_nginx

9.9 容器导入

#因为有centos镜像正在使用,想删除镜像,要先删除容器
#导入命令只生成镜像,不生成容器

[root@localhost opt]# docker stop f3754aa308bd
f3754aa308bd
[root@localhost opt]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS                        PORTS     NAMES
c794a69bf6ce   centos:7       "/bin/bash"              26 minutes ago   Exited (0) 26 minutes ago               hopeful_shtern
f3754aa308bd   centos:7       "/bin/bash"              29 minutes ago   Exited (137) 16 seconds ago             busy_moore
4e0245a200ff   nginx:latest   "/docker-entrypoint.…"   29 minutes ago   Up 29 minutes                 80/tcp    confident_cohen
[root@localhost opt]# docker rmi 8652b9f0cb4c
Error response from daemon: conflict: unable to delete 8652b9f0cb4c (must be forced) - image is being used by stopped container c794a69bf6ce
[root@localhost opt]# docker rm `docker ps -aq`
c794a69bf6ce
f3754aa308bd
Error response from daemon: You cannot remove a running container 4e0245a200ffb43b45b320f9b413616e7d14e8b5e304690e1d6622528a248fa2. Stop the container before attempting removal or force remove
[root@localhost opt]# docker rmi 8652b9f0cb4c
Untagged: centos:7
Untagged: centos@sha256:0f4ec88e21daf75124b8a9e5ca03c37a5e937e0e108a255d890492430789b60e
Deleted: sha256:8652b9f0cb4c0599575e5a003f5906876e10c1ceb2ab9fe1786712dac14a50cf
Deleted: sha256:174f5685490326fc0a1c0f5570b8663732189b327007e47ff13d2ca59673db02
[root@localhost opt]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
nginx        latest    f6d0b4767a6c   2 months ago   133MB[root@localhost opt]# cat /opt/cent | docker import - centos:os-7        #容器导入(centos名称:os-7标签)
sha256:400cf047cbc5df149e70efe6fe8a048aaed8d888bb1d4a292e96695b0cfd24d5
[root@localhost opt]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED         SIZE
centos       os-7      400cf047cbc5   4 seconds ago   286MB
nginx        latest    f6d0b4767a6c   2 months ago    133MB

十、私有库创建

[root@localhost ~]# docker pull registry        #下载私有库内容
Using default tag: latest
latest: Pulling from library/registry
0a6724ff3fcd: Pull complete
d550a247d74f: Pull complete
1a938458ca36: Pull complete
acd758c36fc9: Pull complete
9af6d68b484a: Pull complete
Digest: sha256:d5459fcb27aecc752520df4b492b08358a1912fcdfa454f7d2101d4b09991daa
Status: Downloaded newer image for registry:latest
docker.io/library/registry:latest
[root@localhost ~]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED          SIZE
centos       os-7      400cf047cbc5   11 minutes ago   286MB
nginx        latest    f6d0b4767a6c   2 months ago     133MB
registry     latest    678dfa38fcfa   3 months ago     26.2MB       #下载后会生成一个镜像[root@localhost ~]# vim /etc/docker/daemon.json                     #修改此配置文件{"insecure-registries":["192.168.238.10:5000"],                     #添加内容,建在哪用哪的IP,端口为5000,注意逗号"registry-mirrors": ["https://4xxglnmv.mirror.aliyuncs.com"]
}
[root@localhost ~]# systemctl restart docker.service [root@localhost ~]# docker create -it registry /bin/bash
70673b43a6157cb802a741b4ff9f0d6748c7f65c89821a895d576f836889ef25
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED             STATUS                       PORTS     NAMES
70673b43a615   registry       "/entrypoint.sh /bin…"   7 seconds ago       Created                                eloquent_hoover
4e0245a200ff   nginx:latest   "/docker-entrypoint.…"   About an hour ago   Exited (137) 5 minutes ago             confident_cohen
[root@localhost ~]# docker start 70673b43a615
70673b43a615
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED              STATUS                       PORTS     NAMES
70673b43a615   registry       "/entrypoint.sh /bin…"   About a minute ago   Exited (127) 3 seconds ago             eloquent_hoover
4e0245a200ff   nginx:latest   "/docker-entrypoint.…"   About an hour ago    Exited (137) 5 minutes ago             confident_cohen[root@localhost ~]# docker run -d -p 5000:5000 -v /data/registry:/tmp/registry registry                宿主机的/data/registry自动创建挂在容器中的/tmp/registry路径
375179e2066255ca9edab271e48fe462722cfd64dee968d70717b6e9c55ecd37
[root@localhost ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED             STATUS                        PORTS                    NAMES
375179e20662   registry       "/entrypoint.sh /etc…"   45 seconds ago      Up 44 seconds                 0.0.0.0:5000->5000/tcp   hardcore_germain                 #端口映射
70673b43a615   registry       "/entrypoint.sh /bin…"   5 minutes ago       Exited (127) 4 minutes ago                             eloquent_hoover
4e0245a200ff   nginx:latest   "/docker-entrypoint.…"   About an hour ago   Exited (137) 10 minutes ago                            confident_cohen
[root@localhost ~]# cd /
[root@localhost /]# ls
bin   data  etc   lib    media  opt   root  sbin  sys  usr              #/data/registry为外部路径
boot  dev   home  lib64  mnt    proc  run   srv   tmp  var              #/tmp/registry是内部路径
[root@localhost /]# cd /data/
[root@localhost data]# ls
registry[root@localhost data]# docker tag nginx:latest 192.168.238.10:5000/nginx
[root@localhost data]# docker images
REPOSITORY                  TAG       IMAGE ID       CREATED          SIZE
centos                      os-7      400cf047cbc5   49 minutes ago   286MB
192.168.238.10:5000/nginx   latest    f6d0b4767a6c   2 months ago     133MB
nginx                       latest    f6d0b4767a6c   2 months ago     133MB
registry                    latest    678dfa38fcfa   3 months ago     26.2MB
[root@localhost data]# docker push 192.168.238.10:5000/nginx:latest
The push refers to repository [192.168.238.10:5000/nginx]
85fcec7ef3ef: Pushed
3e5288f7a70f: Pushed
56bc37de0858: Pushed
1c91bf69a08b: Pushed
cb42413394c4: Pushed
latest: digest: sha256:0b159cd1ee1203dad901967ac55eee18c24da84ba3be384690304be93538bea8 size: 1362[root@localhost data]# curl -XGET http://192.168.238.10:5000/v2/_catalog         #获取私有仓库列表
{"repositories":["nginx"]}                  #显示上传成功[root@localhost data]# docker images
REPOSITORY                  TAG       IMAGE ID       CREATED             SIZE
centos                      os-7      400cf047cbc5   About an hour ago   286MB
nginx                       latest    f6d0b4767a6c   2 months ago        133MB          #准备上传
192.168.238.10:5000/nginx   latest    f6d0b4767a6c   2 months ago        133MB
registry                    latest    678dfa38fcfa   3 months ago        26.2MB
[root@localhost data]# docker tag centos:os-7 192.168.238.10:5000/centos7              #打标签
[root@localhost data]# docker images
REPOSITORY                    TAG       IMAGE ID       CREATED             SIZE
192.168.238.10:5000/centos7   latest    400cf047cbc5   About an hour ago   286MB
centos                        os-7      400cf047cbc5   About an hour ago   286MB        #标签
192.168.238.10:5000/nginx     latest    f6d0b4767a6c   2 months ago        133MB
nginx                         latest    f6d0b4767a6c   2 months ago        133MB
registry                      latest    678dfa38fcfa   3 months ago        26.2MB
[root@localhost data]# docker push 192.168.238.10:5000/centos7                         #上传
Using default tag: latest
The push refers to repository [192.168.238.10:5000/centos7]
957f31ef0423: Pushed
latest: digest: sha256:1751611aaad689a82346edd08f1c2b3525554fd9b2a9f00c625bdfec47033311 size: 529
[root@localhost data]# curl -XGET http://192.168.238.10:5000/v2/_catalog
{"repositories":["centos7","nginx"]}                                                  #验证
#删除不需要的容器
[root@localhost data]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED             STATUS                           PORTS                    NAMES
375179e20662   registry       "/entrypoint.sh /etc…"   57 minutes ago      Up 16 minutes                    0.0.0.0:5000->5000/tcp   hardcore_germain                  #只保留端口映射
70673b43a615   registry       "/entrypoint.sh /bin…"   About an hour ago   Exited (127) About an hour ago                            eloquent_hoover
4e0245a200ff   nginx:latest   "/docker-entrypoint.…"   2 hours ago         Exited (137) About an hour ago                            confident_cohen
[root@localhost data]# docker rm 4e0245a200ff
4e0245a200ff
[root@localhost data]# docker rm 70673b43a615
70673b43a615[root@localhost data]# docker ps -a
CONTAINER ID   IMAGE      COMMAND                  CREATED          STATUS          PORTS                    NAMES
375179e20662   registry   "/entrypoint.sh /etc…"   58 minutes ago   Up 17 minutes   0.0.0.0:5000->5000/tcp   hardcore_germain
#删除不需要的镜像
[root@localhost data]# docker images
REPOSITORY                    TAG       IMAGE ID       CREATED             SIZE
centos                        os-7      400cf047cbc5   About an hour ago   286MB
192.168.238.10:5000/centos7   latest    400cf047cbc5   About an hour ago   286MB
192.168.238.10:5000/nginx     latest    f6d0b4767a6c   2 months ago        133MB
nginx                         latest    f6d0b4767a6c   2 months ago        133MB
registry                      latest    678dfa38fcfa   3 months ago        26.2MB
[root@localhost data]# docker rmi centos
Error: No such image: centos
[root@localhost data]# docker rmi centos:os-7
Untagged: centos:os-7
[root@localhost data]# docker rmi 192.168.238.10:5000/centos7:latest
Untagged: 192.168.238.10:5000/centos7:latest
Untagged: 192.168.238.10:5000/centos7@sha256:1751611aaad689a82346edd08f1c2b3525554fd9b2a9f00c625bdfec47033311
Deleted: sha256:400cf047cbc5df149e70efe6fe8a048aaed8d888bb1d4a292e96695b0cfd24d5
Deleted: sha256:957f31ef0423eab08fa8228e7e1946d5f3097aa6fffbe6a3edca59d06823ff7a
[root@localhost data]# docker rmi nginx:latest
Untagged: nginx:latest
[root@localhost data]# docker rmi 192.168.238.10:5000/nginx:latest
Untagged: 192.168.238.10:5000/nginx:latest
Untagged: 192.168.238.10:5000/nginx@sha256:0b159cd1ee1203dad901967ac55eee18c24da84ba3be384690304be93538bea8
Deleted: sha256:f6d0b4767a6c466c178bf718f99bea0d3742b26679081e52dbf8e0c7c4c42d74
Deleted: sha256:4dfe71c4470c5920135f00af483556b09911b72547113512d36dc29bfc5f7445
Deleted: sha256:3c90a0917c79b758d74b7040f62d17a7680cd14077f734330b1994a2985283b8
Deleted: sha256:a1c538085c6f891424160d8db120ea093d4dda393e94cd4713e3fff3c82299b5
Deleted: sha256:a3ee2510dcf02c980d7aff635909612006fd1662084d6225e52e769b984abeb5
Deleted: sha256:cb42413394c4059335228c137fe884ff3ab8946a014014309676c25e3ac86864[root@localhost data]# docker images
REPOSITORY   TAG       IMAGE ID       CREATED        SIZE
registry     latest    678dfa38fcfa   3 months ago   26.2MB             #只保留registry
#从私有仓库下载镜像
[root@localhost data]# docker pull 192.168.238.10:5000/nginx
Using default tag: latest
latest: Pulling from nginx
a076a628af6f: Pull complete
0732ab25fa22: Pull complete
d7f36f6fe38f: Pull complete
f72584a26f32: Pull complete
7125e4df9063: Pull complete
Digest: sha256:0b159cd1ee1203dad901967ac55eee18c24da84ba3be384690304be93538bea8
Status: Downloaded newer image for 192.168.238.10:5000/nginx:latest
192.168.238.10:5000/nginx:latest[root@localhost data]# docker pull 192.168.238.10:5000/centos7
Using default tag: latest
latest: Pulling from centos7
549d636f0460: Pull complete
Digest: sha256:1751611aaad689a82346edd08f1c2b3525554fd9b2a9f00c625bdfec47033311
Status: Downloaded newer image for 192.168.238.10:5000/centos7:latest
192.168.238.10:5000/centos7:latest[root@localhost data]# docker images
REPOSITORY                    TAG       IMAGE ID       CREATED        SIZE
192.168.238.10:5000/centos7   latest    400cf047cbc5   2 hours ago    286MB
192.168.238.10:5000/nginx     latest    f6d0b4767a6c   2 months ago   133MB
registry                      latest    678dfa38fcfa   3 months ago   26.2MB

十一、docker容器卷

宿主机目录/share挂载容器中的/data1

[root@localhost data]# docker run -v /share:/data1 --name xyw1 -it centos /bin/bash
Unable to find image 'centos:latest' locally
latest: Pulling from library/centos
7a0437f04f83: Pull complete
Digest: sha256:5528e8b1b1719d34604c87e11dcd1c0a20bedf46e83b5632cdeac91b8c04efc1
Status: Downloaded newer image for centos:latest[root@67f9702eb629 /]# ls              #进入容器
bin    dev  home  lib64       media  opt   root  sbin  sys  usr
data1  etc  lib   lost+found  mnt    proc  run  srv   tmp  var
[root@67f9702eb629 /]# cd data1/
[root@67f9702eb629 data1]# ls
[root@67f9702eb629 data1]# touch abc
[root@67f9702eb629 data1]# ls
abc
[root@67f9702eb629 data1]# exit
exit
[root@localhost data]# cd /share/
[root@localhost share]# ls
abc

十二、数据卷容器

[root@localhost share]# docker run --name xyw100 -v /data1 -v /data2 -it centos /bin/bash
[root@4fd2f053bd45 /]# ls                      #xyw100
bin    data2  etc   lib    lost+found  mnt  proc  run  srv  tmp  var
data1  dev    home  lib64  media       opt  root  sbin  sys  usr
[root@4fd2f053bd45 /]# cd data1
[root@4fd2f053bd45 data1]# ls[root@localhost ~]# docker run -it --volumes-from xyw100 --name xyw200 centos /bin/bash
[root@a872b9673627 /]# ls                      #xyw200
bin    data2  etc   lib    lost+found  mnt  proc  run  srv  tmp  var
data1  dev    home  lib64  media       opt  root  sbin  sys  usr
[root@a872b9673627 /]# cd data1
[root@a872b9673627 data1]# touch abc
[root@a872b9673627 data1]# ls
abc[root@4fd2f053bd45 data1]# ls                   #xyw100
abc
[root@localhost share]# docker ps -a
CONTAINER ID   IMAGE      COMMAND                  CREATED          STATUS                      PORTS                    NAMES
a872b9673627   centos     "/bin/bash"              4 minutes ago    Up 4 minutes                                         xyw200
4fd2f053bd45   centos     "/bin/bash"              6 minutes ago    Exited (0) 24 seconds ago                            xyw100
67f9702eb629   centos     "/bin/bash"              11 minutes ago   Exited (0) 10 minutes ago                            xyw1
375179e20662   registry   "/entrypoint.sh /etc…"   2 hours ago      Up 51 minutes               0.0.0.0:5000->5000/tcp   hardcore_germain

十三、端口映射

-P指定随机端口

[root@localhost share]# docker run -d -P nginx              #-P指定随机端口
Unable to find image 'nginx:latest' locally
latest: Pulling from library/nginx
Digest: sha256:10b8cc432d56da8b61b070f4c7d2543a9ed17c2b23010b43af434fd40e2ca4aa
Status: Downloaded newer image for nginx:latest
1efdce46fc89e3e8f8e0842b3089dcbce911e910b71b468dacc8ad852cd8ff4b[root@localhost share]# docker ps -a
CONTAINER ID   IMAGE      COMMAND                  CREATED          STATUS                      PORTS                    NAMES
1efdce46fc89   nginx      "/docker-entrypoint.…"   4 seconds ago    Up 3 seconds                0.0.0.0:49153->80/tcp    affectionate_dewdney              #端口为49153
a872b9673627   centos     "/bin/bash"              6 minutes ago    Up 6 minutes                                         xyw200
4fd2f053bd45   centos     "/bin/bash"              8 minutes ago    Exited (0) 2 minutes ago                             xyw100
67f9702eb629   centos     "/bin/bash"              13 minutes ago   Exited (0) 11 minutes ago                            xyw1
375179e20662   registry   "/entrypoint.sh /etc…"   2 hours ago      Up 52 minutes               0.0.0.0:5000->5000/tcp   hardcore_germain


-p指定特定端口

[root@localhost share]# docker run -d -p 47777:80 nginx
d80d0a9c195ddd4df76fe8b732555d7e1199c2b7a4ca85092a35ebb17bcd8ad6
[root@localhost share]# docker ps -a
CONTAINER ID   IMAGE      COMMAND                  CREATED          STATUS                      PORTS                    NAMES
d80d0a9c195d   nginx      "/docker-entrypoint.…"   25 seconds ago   Up 24 seconds               0.0.0.0:47777->80/tcp    kind_easley
1efdce46fc89   nginx      "/docker-entrypoint.…"   5 minutes ago    Up 5 minutes                0.0.0.0:49153->80/tcp    affectionate_dewdney
a872b9673627   centos     "/bin/bash"              11 minutes ago   Up 11 minutes                                        xyw200
4fd2f053bd45   centos     "/bin/bash"              13 minutes ago   Exited (0) 7 minutes ago                             xyw100
67f9702eb629   centos     "/bin/bash"              18 minutes ago   Exited (0) 17 minutes ago                            xyw1
375179e20662   registry   "/entrypoint.sh /etc…"   2 hours ago      Up 58 minutes               0.0.0.0:5000->5000/tcp   hardcore_germain

十四、容器互联(使用centos镜像)

[root@localhost share]# docker run -itd -P --name web1 centos /bin/bash
150f93592c4d1aef2d7e3999eebba054161b7d9b44c7930560765bd27df2fa43[root@localhost share]# docker run -itd -P --name web2 --link web1:web1 centos /bin/bash       第二个web1是别名,验证ping就要ping它
2afa140f8b4ecc180df348ae73ec82c40391b8d6b9c7b79374895956aac2edf3[root@localhost share]# docker ps -a
CONTAINER ID   IMAGE      COMMAND                  CREATED              STATUS                         PORTS                    NAMES
2afa140f8b4e   centos     "/bin/bash"              6 seconds ago        Up 6 seconds                                            web2                      #web2
150f93592c4d   centos     "/bin/bash"              About a minute ago   Up About a minute                                       web1                      #web1
d80d0a9c195d   nginx      "/docker-entrypoint.…"   About an hour ago    Up About an hour               0.0.0.0:47777->80/tcp    kind_easley
1efdce46fc89   nginx      "/docker-entrypoint.…"   About an hour ago    Up About an hour               0.0.0.0:49153->80/tcp    affectionate_dewdney
a872b9673627   centos     "/bin/bash"              About an hour ago    Up About an hour                                        xyw200
4fd2f053bd45   centos     "/bin/bash"              About an hour ago    Exited (0) About an hour ago                            xyw100
67f9702eb629   centos     "/bin/bash"              2 hours ago          Exited (0) 2 hours ago                                  xyw1
375179e20662   registry   "/entrypoint.sh /etc…"   3 hours ago          Up 2 hours                     0.0.0.0:5000->5000/tcp   hardcore_germain
[root@localhost share]# docker exec -it 150f93592c4d /bin/bash      #进入web1
[root@150f93592c4d /]# ping web2                           #这里ping不通,是因为命令做的是连接web1,别名创建的也是web1,所以应该进入web2内,ping web1
ping: web2: Name or service not known
[root@localhost share]# docker exec -it 2afa140f8b4e /bin/bash          #进入web2[root@2afa140f8b4e /]# ping web1                                        #ping web1 ,此处的web1是别名
PING web1 (172.17.0.6) 56(84) bytes of data.
64 bytes from web1 (172.17.0.6): icmp_seq=1 ttl=64 time=0.079 ms
64 bytes from web1 (172.17.0.6): icmp_seq=2 ttl=64 time=0.067 ms
64 bytes from web1 (172.17.0.6): icmp_seq=3 ttl=64 time=0.135 ms
64 bytes from web1 (172.17.0.6): icmp_seq=4 ttl=64 time=0.057 ms
64 bytes from web1 (172.17.0.6): icmp_seq=5 ttl=64 time=0.120 ms
64 bytes from web1 (172.17.0.6): icmp_seq=6 ttl=64 time=0.121 ms
64 bytes from web1 (172.17.0.6): icmp_seq=7 ttl=64 time=0.121 ms
^C
--- web1 ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 7ms
rtt min/avg/max/mdev = 0.057/0.100/0.135/0.029 ms

十五、编写脚本的流程

1、根据需求定义变量
2、选用流程控制语句
3、试写功能
4、优化代码
5、BUG处理(异常)
6、想想第二种方法

Docker------基础命令、容器卷、容器互联相关推荐

  1. Docker 安装 命令 数据卷 应用部署 网络优化 Dockerfile 服务编排Compose 私有仓库

    Docker 1. 初识docker 1.1 Docker是什么 了解Docker的前生LXC LXC与docker的关系 Docker 的特点 1.2 为什么使用Docker Docker的优势 缺 ...

  2. docker基础命令操作

    docker基础命令操作 一.容器生命周期管理 1.1 run 1.2 启动.停止.重启容器 1.3 kill--杀掉一个运行中的容器 1.4 rm--删除容器 1.5 pause/unpause 命 ...

  3. 企业版Docker2——Docker基础命令详解

    记住:容器是基于镜像的,就像虚拟机也是基于镜像一样的 1.常用的Docker基础命令总结 2.命令的详细说明与演示 (1)docker create docker create 命令为指定的镜像(im ...

  4. Docker学习(2)——图文并茂讲解Docker基础命令

    一.Docker基础命令总结 命令 功能 docker load -i ubuntu.tar 导入镜像 docker run -it --name vm1 ubuntu 创建容器(以ubuntu镜像为 ...

  5. Docker基础命令学习

    Docker基础命令学习 二.Docker 入门 Docker是什么? Docker 是一个开源的应用容器引擎,你可以将其理解为一个轻量级的虚拟机,开发者可以打包他们的应用以及依赖包到一个可移植的容器 ...

  6. docker几个基础命令及nodejs容器

    最近在了解docker使用,在网上找资料发现很少有可以系统的了解某一个操作目的的大部分细节的参考,学起来非常吃力.耗时. 这里整理了一下自己在入门摸索过程中的几个入门级的操作,可以连贯的对实现一个no ...

  7. docker 基础命令 ,容器存为镜像,载入镜像,生成容器

    导入镜像 docker load < images.tar.gz 创建容器 docker run -itd --shm-size=64G --privileged=true -v /home:/ ...

  8. Docker基础之九: 管理容器的数据

    管理容器的数据 (对Docker感兴趣的朋友可以加我的微信ghostcloud2016,然后我把你加到我们的一个Docker爱好者群组里面.) 到目前为止,我们已经介绍了Docker的一些基本概念,如 ...

  9. Docker 常用命令 - 镜像与容器

    Docker命令,可参见官网:Reference documentation | Docker Documentation 查看docker版本(version) docker version [ro ...

  10. Docker 基础命令学习

    容器生命周期管理 docker run docker run :创建一个新的容器并运行一个命令. 参数: -a stdin: 指定标准输入输出内容类型,可选 STDIN/STDOUT/STDERR 三 ...

最新文章

  1. 车道线检测综述及新工作汇总
  2. LightRoom操作快捷键
  3. 我理解的【旁路代理】
  4. 使用【python语言】和【typescript】进行冒泡排序
  5. Redis学习笔记~分布式的Pub/Sub模式
  6. Qt多线程-QThread
  7. JSPatch源码解读
  8. k8s学习: 创建 mysql 任务
  9. cart算法 java_决策树学习笔记(三):CART算法,决策树总结
  10. 最像XP的中文Linux,和XP一模一样的Linux系统
  11. mos管的rc吸收电路计算_RC吸收电路参数计算
  12. Spring源码杂集
  13. 上海网站备案人工服务器,上海网站备案中心
  14. 阿里开放平台接入——开放平台注册与API调用
  15. kettle导数据入HBase数据库报错解决
  16. Android内存泄漏检测工具使用手册
  17. 东北农业大学计算机科学与技术复试名单,更新!最新182所院校复试信息汇总
  18. 泽塔云:用超融合撑起软件定义数据中心的梦想
  19. Matlab界面语言切换,自由显示中文或英文语言
  20. android 手机资源获取失败,三、解决android手机IMEI获取失败终极方案,自定义IMIE,主板+系统定制商+cup指令集+设备参数+显示屏参数+修订版列表等参数生成IMIEI...

热门文章

  1. 7. QFile读写文件的基本操作
  2. 汉字转拼音之pinyin4j 简单使用
  3. 微信小程序开发之——视图全屏显示
  4. 沉思录| Kotlin的「丑与美」,以及「最佳实践」
  5. requests库的使用(一篇就够了)
  6. vivoy73s和oppoa92s哪个好
  7. springboot+vue项目之MOBA类游戏攻略分享平台(java项目源码+文档)
  8. 下载jdk8登录账号
  9. Python 字典的基本操作
  10. java st_st.java · cwj/java201621123070 - Gitee.com