docker day001

Connecting to 192.168.199.235:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Last login: Sat Jul 11 18:18:01 2020 from laptop-r2s5kmd1.lan
[sn@localhost ~]$ mkdir -p /etc/docker
[sn@localhost ~]$ vim  /etc/docker/daemon.json
[sn@localhost ~]$ su root 
密码:
[root@localhost sn]# vim  /etc/docker/daemon.json
[root@localhost sn]# cat /etc/docker/daemon.json
{"registry-mirrors": ["http://hub-mirror.c.163.com"] }



[root@localhost sn]# systemctl daemon-reload
[root@localhost sn]# systemctl restart docker
[root@localhost sn]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
[root@localhost sn]# docker pull tomcat
Using default tag: latest
latest: Pulling from library/tomcat
e9afc4f90ab0: Already exists 
989e6b19a265: Already exists 
af14b6c2f878: Already exists 
5573c4b30949: Already exists 
fb1a405f128d: Already exists 
612a9f566fdc: Already exists 
cf63ebed1142: Downloading [=====================>                             ]  84.82MB/196.2MB
fbb20561cd50: Download complete 
76c915a2cfb7: Download complete 
a2c2864c3363: Download complete 
^C
[root@localhost sn]# ^C
[root@localhost sn]# ^C
[root@localhost sn]# ^C
[root@localhost sn]# ^C
[root@localhost sn]# vim  /etc/docker/daemon.json
[root@localhost sn]# cat  /etc/docker/daemon.json
{"registry-mirrors": ["http://xxxx.mirror.aliyuncs.com"] }



[root@localhost sn]# systemctl daemon-reload
[root@localhost sn]# systemctl restart docker
[root@localhost sn]# docker pull tomcat
Using default tag: latest
latest: Pulling from library/tomcat
e9afc4f90ab0: Pull complete 
989e6b19a265: Pull complete 
af14b6c2f878: Pull complete 
5573c4b30949: Pull complete 
fb1a405f128d: Pull complete 
612a9f566fdc: Pull complete 
cf63ebed1142: Pull complete 
fbb20561cd50: Pull complete 
76c915a2cfb7: Pull complete 
a2c2864c3363: Pull complete 
Digest: sha256:11f247df062558074169fb92a54033ab2eb6563bda9765b3a9e53106db3c2f4a
Status: Downloaded newer image for tomcat:latest
docker.io/library/tomcat:latest
[root@localhost sn]# docker imags
docker: 'imags' is not a docker command.
See 'docker --help'
[root@localhost sn]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tomcat              latest              6055d4d564e1        4 days ago          647MB
[root@localhost sn]# git pull centos
bash: git: 未找到命令...
[root@localhost sn]# docker  pull centos
Using default tag: latest
latest: Pulling from library/centos
6910e5a164f7: Pull complete 
Digest: sha256:4062bbdd1bb0801b0aa38e0f83dece70fb7a5e9bce223423a68de2d8b784b43b
Status: Downloaded newer image for centos:latest
docker.io/library/centos:latest
[root@localhost sn]# 
[root@localhost sn]# 
[root@localhost sn]# 
[root@localhost sn]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tomcat              latest              6055d4d564e1        4 days ago          647MB
centos              latest              831691599b88        3 weeks ago         215MB
[root@localhost sn]# docker run -it centos
[root@f796788742d3 /]# ll
bash: ll: command not found
[root@f796788742d3 /]# ls
bin  dev  etc  home  lib  lib64  lost+found  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
[root@f796788742d3 /]# 
[root@f796788742d3 /]# 
[root@f796788742d3 /]# 
[root@f796788742d3 /]# rz -y
bash: rz: command not found
[root@f796788742d3 /]# cd ..
[root@f796788742d3 /]# ll
bash: ll: command not found
[root@f796788742d3 /]# ll
bash: ll: command not found
[root@f796788742d3 /]# cd ..
[root@f796788742d3 /]# exit
exit
[root@localhost sn]# 
[root@localhost sn]# 
[root@localhost sn]# 
[root@localhost sn]# ll
总用量 0
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 公共
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 模板
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 视频
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 图片
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 文档
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 下载
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 音乐
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 桌面
[root@localhost sn]# ll
总用量 0
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 公共
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 模板
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 视频
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 图片
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 文档
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 下载
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 音乐
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 桌面
[root@localhost sn]# cd ..
[root@localhost home]# ll
总用量 4
drwx------. 15 sn sn 4096 7月  11 18:34 sn
[root@localhost home]# cd ..
[root@localhost /]# ll
总用量 20
lrwxrwxrwx.   1 root root    7 7月  11 18:01 bin -> usr/bin
dr-xr-xr-x.   5 root root 4096 7月  11 18:12 boot
drwxr-xr-x.  20 root root 3320 7月  11 18:13 dev
drwxr-xr-x. 140 root root 8192 7月  11 18:31 etc
drwxr-xr-x.   3 root root   16 7月  11 18:11 home
lrwxrwxrwx.   1 root root    7 7月  11 18:01 lib -> usr/lib
lrwxrwxrwx.   1 root root    9 7月  11 18:01 lib64 -> usr/lib64
drwxr-xr-x.   2 root root    6 4月  11 2018 media
drwxr-xr-x.   2 root root    6 4月  11 2018 mnt
drwxr-xr-x.   4 root root   34 7月  11 18:31 opt
dr-xr-xr-x. 229 root root    0 7月  11 18:13 proc
dr-xr-x---.   6 root root  212 7月  11 18:40 root
drwxr-xr-x.  41 root root 1300 7月  11 18:41 run
lrwxrwxrwx.   1 root root    8 7月  11 18:01 sbin -> usr/sbin
drwxr-xr-x.   2 root root    6 4月  11 2018 srv
dr-xr-xr-x.  13 root root    0 7月  11 18:13 sys
drwxrwxrwt.  17 root root 4096 7月  11 18:58 tmp
drwxr-xr-x.  13 root root  155 7月  11 18:01 usr
drwxr-xr-x.  20 root root  282 7月  11 18:13 var
[root@localhost /]# cd /usr
[root@localhost usr]# ll
总用量 268
dr-xr-xr-x.   2 root root 49152 7月  11 18:31 bin
drwxr-xr-x.   2 root root     6 4月  11 2018 etc
drwxr-xr-x.   2 root root     6 4月  11 2018 games
drwxr-xr-x.  41 root root  8192 7月  11 18:26 include
dr-xr-xr-x.  43 root root  4096 7月  11 18:24 lib
dr-xr-xr-x. 141 root root 81920 7月  11 18:27 lib64
drwxr-xr-x.  48 root root 12288 7月  11 18:31 libexec
drwxr-xr-x.  12 root root   131 7月  11 18:01 local
dr-xr-xr-x.   2 root root 20480 7月  11 18:27 sbin
drwxr-xr-x. 235 root root  8192 7月  11 18:31 share
drwxr-xr-x.   4 root root    34 7月  11 18:01 src
lrwxrwxrwx.   1 root root    10 7月  11 18:01 tmp -> ../var/tmp
[root@localhost usr]# cd home
bash: cd: home: 没有那个文件或目录
[root@localhost usr]# ll
总用量 268
dr-xr-xr-x.   2 root root 49152 7月  11 18:31 bin
drwxr-xr-x.   2 root root     6 4月  11 2018 etc
drwxr-xr-x.   2 root root     6 4月  11 2018 games
drwxr-xr-x.  41 root root  8192 7月  11 18:26 include
dr-xr-xr-x.  43 root root  4096 7月  11 18:24 lib
dr-xr-xr-x. 141 root root 81920 7月  11 18:27 lib64
drwxr-xr-x.  48 root root 12288 7月  11 18:31 libexec
drwxr-xr-x.  12 root root   131 7月  11 18:01 local
dr-xr-xr-x.   2 root root 20480 7月  11 18:27 sbin
drwxr-xr-x. 235 root root  8192 7月  11 18:31 share
drwxr-xr-x.   4 root root    34 7月  11 18:01 src
lrwxrwxrwx.   1 root root    10 7月  11 18:01 tmp -> ../var/tmp
[root@localhost usr]# cd ../home
[root@localhost home]# ll
总用量 4
drwx------. 15 sn sn 4096 7月  11 18:34 sn
[root@localhost home]# cd sn
[root@localhost sn]# ll
总用量 0
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 公共
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 模板
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 视频
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 图片
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 文档
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 下载
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 音乐
drwxr-xr-x. 2 sn sn 6 7月  11 18:14 桌面
[root@localhost sn]# docker info
Client:
 Debug Mode: false

Server:
 Containers: 1
  Running: 0
  Paused: 0
  Stopped: 1
 Images: 2
 Server Version: 19.03.12
 Storage Driver: overlay2
  Backing Filesystem: xfs
  Supports d_type: true
  Native Overlay Diff: true
 Logging Driver: json-file
 Cgroup Driver: cgroupfs
 Plugins:
  Volume: local
  Network: bridge host ipvlan macvlan null overlay
  Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
 Swarm: inactive
 Runtimes: runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 7ad184331fa3e55e52b890ea95e65ba581ae3429
 runc version: dc9208a3303feef5b3839f4323d9beb36df0a9dd
 init version: fec3683
 Security Options:
  seccomp
   Profile: default
 Kernel Version: 3.10.0-957.el7.x86_64
 Operating System: CentOS Linux 7 (Core)
 OSType: linux
 Architecture: x86_64
 CPUs: 1
 Total Memory: 982.1MiB
 Name: localhost.localdomain
 ID: ICXX:O6WQ:A3SB:YD37:MNDO:CPSR:4DRE:DOVL:DBS5:NFVG:F534:FBPO
 Docker Root Dir: /var/lib/docker
 Debug Mode: false
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  127.0.0.0/8
 Registry Mirrors:
  http://5utbdecc.mirror.aliyuncs.com/
 Live Restore Enabled: false

[root@localhost sn]# 
[root@localhost sn]# 
[root@localhost sn]# 
[root@localhost sn]# docker imagas
docker: 'imagas' is not a docker command.
See 'docker --help'
[root@localhost sn]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
tomcat              latest              6055d4d564e1        4 days ago          647MB
centos              latest              831691599b88        3 weeks ago         215MB
[root@localhost sn]# docker run -it centos
[root@a91ec309056f /]# ll
bash: ll: command not found
[root@a91ec309056f /]# ifconfig
bash: ifconfig: command not found
[root@a91ec309056f /]# vim
bash: vim: command not found
[root@a91ec309056f /]# exit
exit
[root@localhost sn]# vim Dockerfile



FROM centos
MAINTAINER zzyy<18612421477@163.com>

ENV MYPATH /usr/local
WORKDIR $MYPATH

RUN yum -y install vim
RUN yum -y install net-tools

EXPOSE 80

CMD echo $MYPATH
CMD echo "success--------------ok"
CMD /bin/bash

 

 

 

 

 


[root@localhost sn]#




[root@localhost sn]# docker build
-t ocrtfcentos7:1.0 . Sending build context to Docker daemon 5.212MB Step 1/10 : FROM centos ---> 831691599b88 Step 2/10 : MAINTAINER zzyy<18612421477@163.com> ---> Running in 870005e08d5a Removing intermediate container 870005e08d5a ---> 38bd44e1f3ba Step 3/10 : ENV MYPATH /usr/local ---> Running in 7121f8e99036 Removing intermediate container 7121f8e99036 ---> 15bce6c5006d Step 4/10 : WORKDIR $MYPATH ---> Running in 5e05e5c59b3a Removing intermediate container 5e05e5c59b3a ---> 9be0fc9f97b3 Step 5/10 : RUN yum -y install vim ---> Running in 0c2a3bff4a7e CentOS-8 - AppStream 1.2 MB/s | 5.8 MB 00:04 CentOS-8 - Base 55 kB/s | 2.2 MB 00:41 CentOS-8 - Extras 7.4 kB/s | 6.7 kB 00:00 Dependencies resolved. ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: vim-enhanced x86_64 2:8.0.1763-13.el8 AppStream 1.4 M Installing dependencies: gpm-libs x86_64 1.20.7-15.el8 AppStream 39 k vim-common x86_64 2:8.0.1763-13.el8 AppStream 6.3 M vim-filesystem noarch 2:8.0.1763-13.el8 AppStream 48 k which x86_64 2.21-12.el8 BaseOS 49 k Transaction Summary ================================================================================ Install 5 Packages Total download size: 7.8 M Installed size: 31 M Downloading Packages: (1/5): gpm-libs-1.20.7-15.el8.x86_64.rpm 66 kB/s | 39 kB 00:00 (2/5): vim-filesystem-8.0.1763-13.el8.noarch.rp 205 kB/s | 48 kB 00:00 (3/5): vim-enhanced-8.0.1763-13.el8.x86_64.rpm 646 kB/s | 1.4 MB 00:02 (4/5): vim-common-8.0.1763-13.el8.x86_64.rpm 688 kB/s | 6.3 MB 00:09 (5/5): which-2.21-12.el8.x86_64.rpm 3.2 kB/s | 49 kB 00:15 -------------------------------------------------------------------------------- Total 406 kB/s | 7.8 MB 00:19 warning: /var/cache/dnf/AppStream-02e86d1c976ab532/packages/gpm-libs-1.20.7-15.el8.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY CentOS-8 - AppStream 1.6 MB/s | 1.6 kB 00:00 Importing GPG key 0x8483C65D: Userid : "CentOS (CentOS Official Signing Key) <security@centos.org>" Fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D From : /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial Key imported successfully Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : which-2.21-12.el8.x86_64 1/5 Installing : vim-filesystem-2:8.0.1763-13.el8.noarch 2/5 Installing : vim-common-2:8.0.1763-13.el8.x86_64 3/5 Installing : gpm-libs-1.20.7-15.el8.x86_64 4/5 Running scriptlet: gpm-libs-1.20.7-15.el8.x86_64 4/5 Installing : vim-enhanced-2:8.0.1763-13.el8.x86_64 5/5 Running scriptlet: vim-enhanced-2:8.0.1763-13.el8.x86_64 5/5 Running scriptlet: vim-common-2:8.0.1763-13.el8.x86_64 5/5 Verifying : gpm-libs-1.20.7-15.el8.x86_64 1/5 Verifying : vim-common-2:8.0.1763-13.el8.x86_64 2/5 Verifying : vim-enhanced-2:8.0.1763-13.el8.x86_64 3/5 Verifying : vim-filesystem-2:8.0.1763-13.el8.noarch 4/5 Verifying : which-2.21-12.el8.x86_64 5/5 Installed: gpm-libs-1.20.7-15.el8.x86_64 vim-common-2:8.0.1763-13.el8.x86_64 vim-enhanced-2:8.0.1763-13.el8.x86_64 vim-filesystem-2:8.0.1763-13.el8.noarch which-2.21-12.el8.x86_64 Complete! Removing intermediate container 0c2a3bff4a7e ---> 4c2887b37e8a Step 6/10 : RUN yum -y install net-tools ---> Running in 5afc1d3d4e0b Last metadata expiration check: 0:00:28 ago on Sat Jul 11 11:09:07 2020. Dependencies resolved. ================================================================================ Package Architecture Version Repository Size ================================================================================ Installing: net-tools x86_64 2.0-0.51.20160912git.el8 BaseOS 323 k Transaction Summary ================================================================================ Install 1 Package Total download size: 323 k Installed size: 1.0 M Downloading Packages: net-tools-2.0-0.51.20160912git.el8.x86_64.rpm 213 kB/s | 323 kB 00:01 -------------------------------------------------------------------------------- Total 150 kB/s | 323 kB 00:02 Running transaction check Transaction check succeeded. Running transaction test Transaction test succeeded. Running transaction Preparing : 1/1 Installing : net-tools-2.0-0.51.20160912git.el8.x86_64 1/1 Running scriptlet: net-tools-2.0-0.51.20160912git.el8.x86_64 1/1 Verifying : net-tools-2.0-0.51.20160912git.el8.x86_64 1/1 Installed: net-tools-2.0-0.51.20160912git.el8.x86_64 Complete! Removing intermediate container 5afc1d3d4e0b ---> 65233bdfcfc4 Step 7/10 : EXPOSE 80 ---> Running in 96d97e4185c2 Removing intermediate container 96d97e4185c2 ---> 9d159d804821 Step 8/10 : CMD echo $MYPATH ---> Running in 2a6730763727 Removing intermediate container 2a6730763727 ---> 0ef735e2bd82 Step 9/10 : CMD echo "success--------------ok" ---> Running in ada10e0e449f Removing intermediate container ada10e0e449f ---> fded136579dc Step 10/10 : CMD /bin/bash ---> Running in 037d13d26633 Removing intermediate container 037d13d26633 ---> 084c6d1f8bda Successfully built 084c6d1f8bda Successfully tagged ocrtfcentos7:1.0 [root@localhost sn]# docker imags docker: 'imags' is not a docker command. See 'docker --help' [root@localhost sn]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE ocrtfcentos7 1.0 084c6d1f8bda 18 seconds ago 295MB tomcat latest 6055d4d564e1 4 days ago 647MB centos latest 831691599b88 3 weeks ago 215MB [root@localhost sn]# docker build -t ocrtfcentos7 "docker build" requires exactly 1 argument. See 'docker build --help'. Usage: docker build [OPTIONS] PATH | URL | - Build an image from a Dockerfile [root@localhost sn]# docker run -it ocrtfcentos7 Unable to find image 'ocrtfcentos7:latest' locally ^[[A^[[A^C [root@localhost sn]# ^C [root@localhost sn]# ^C [root@localhost sn]# docker run -it 084c6d1f8bda [root@72b1de9bf6ea local]# [root@72b1de9bf6ea local]# [root@72b1de9bf6ea local]# [root@72b1de9bf6ea local]# ll bash: ll: command not found [root@72b1de9bf6ea local]# ls bin etc games include lib lib64 libexec sbin share src [root@72b1de9bf6ea local]# ifconfig eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.17.0.2 netmask 255.255.0.0 broadcast 172.17.255.255 ether 02:42:ac:11:00:02 txqueuelen 0 (Ethernet) RX packets 7 bytes 586 (586.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536 inet 127.0.0.1 netmask 255.0.0.0 loop txqueuelen 1000 (Local Loopback) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@72b1de9bf6ea local]# vim tt [root@72b1de9bf6ea local]# [root@72b1de9bf6ea local]# [root@72b1de9bf6ea local]# ll bash: ll: command not found [root@72b1de9bf6ea local]# ls bin etc games include lib lib64 libexec sbin share src [root@72b1de9bf6ea local]#

 

posted @ 2020-07-11 19:19  Alamps  阅读(304)  评论(0编辑  收藏  举报