04 Docker常用命令

帮助命令

docker version      # 显示docker版本信息
docker info         # 显示docker的系统信息
docker 命令 --help   # 帮助命令

帮助文档位置:https://docs.docker.com/reference/

镜像命令

docker images 查看所有本地的主机上的镜像

帮助文档地址:https://docs.docker.com/engine/reference/commandline/images/

[hekai@localhost docker]$ docker images
REPOSITORY                       TAG       IMAGE ID       CREATED         SIZE
hello-world                      latest    d1165f221234   31 hours ago    13.3kB
# 解释
REPOSITORY  镜像的仓库源
TAG         镜像的标签
IMAGE ID    镜像的id
CREATED     镜像的创建时间
SIZE        镜像的大小

# 不会可以使用--help查看选项
[hekai@localhost docker]$ docker images --help
Usage:  docker images [OPTIONS] [REPOSITORY[:TAG]]

List images

Options:
  -a, --all             Show all images (default hides intermediate images)
      --digests         Show digests
  -f, --filter filter   Filter output based on conditions provided
      --format string   Pretty-print images using a Go template
      --no-trunc        Don't truncate output
  -q, --quiet           Only show numeric IDs

# 所有命令的学习都类似

docker search 被搜索的镜像名

dockerhub也可以搜索:https://hub.docker.com/

# 命令行搜索mysql
[hekai@localhost ~]$ docker images search mysql
NAME                              DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql                             MySQL is a widely used, open-source relation…   10583     [OK]
mariadb                           MariaDB Server is a high performing open sou…   3960      [OK]
mysql/mysql-server                Optimized MySQL Server Docker images. Create…   776                  [OK]

网页搜索



# 参数查看
[hekai@localhost ~]$ docker search --help

Usage:  docker search [OPTIONS] TERM

Search the Docker Hub for images

Options:
  -f, --filter filter   Filter output based on conditions provided
      --format string   Pretty-print search using a Go template
      --limit int       Max number of search results (default 25)
      --no-trunc        Don't truncate output
      
# 使用--filter搜索过滤
[hekai@localhost ~]$ docker search mysql --filter=STARS=3000
NAME      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql     MySQL is a widely used, open-source relation…   10583     [OK]
mariadb   MariaDB Server is a high performing open sou…   3960      [OK]

[hekai@localhost ~]$ docker search mysql --filter=STARS=5000
NAME      DESCRIPTION                                     STARS     OFFICIAL   AUTOMATED
mysql     MySQL is a widely used, open-source relation…   10583     [OK]

docker pull 要下载的镜像名

# docker pull 镜像名:tag
# 首先看一下--help
[hekai@localhost ~]$ docker pull --help

Usage:  docker pull [OPTIONS] NAME[:TAG|@DIGEST]

Pull an image or a repository from a registry

Options:
  -a, --all-tags                Download all tagged images in the repository
      --disable-content-trust   Skip image verification (default true)
      --platform string         Set platform if server is multi-platform capable
  -q, --quiet                   Suppress verbose output

# 尝试使用下载mysql
[hekai@localhost ~]$ docker pull mysql
Using default tag: latest           # 不加tag,默认就是latest
latest: Pulling from library/mysql
45b42c59be33: Pull complete         # 分层下载,docker image核心:联合文件系统
b4f790bd91da: Pull complete
325ae51788e9: Pull complete
adcb9439d751: Pull complete
174c7fe16c78: Pull complete
698058ef136c: Pull complete
4690143a669e: Pull complete
f7599a246fd6: Pull complete
35a55bf0c196: Pull complete
790ac54f4c47: Pull complete
b0ddd5d1b543: Pull complete
1aefd67cb33d: Pull complete
Digest: sha256:7706e4c382be813b58ef514f2bdac747cd463a6866c6c81165d42a1d0e4fe947 # 签名
Status: Downloaded newer image for mysql:latest
docker.io/library/mysql:latest  # 真实地址

# 上面命令等价于
docker pull docker.io/library/mysql:latest

# 指定版本下载,要从dockerhub查看,要有的版本添加tag
[hekai@localhost ~]$ docker pull mysql:5.7
5.7: Pulling from library/mysql
45b42c59be33: Already exists
b4f790bd91da: Already exists
325ae51788e9: Already exists
adcb9439d751: Already exists
174c7fe16c78: Already exists
698058ef136c: Already exists
4690143a669e: Already exists
66676c1ab9b3: Pull complete
25ebf78a38b6: Pull complete
a6510e5d6228: Pull complete
90ca045d52c5: Pull complete
Digest: sha256:9fc60b229633ce1d1f2ee306705152d4b001056fb27c1b5debe23a732df72b70
Status: Downloaded newer image for mysql:5.7
docker.io/library/mysql:5.7

docker rmi 要删除的镜像名

# 查看帮助文档可以使用参数进行删除处理
[hekai@localhost ~]$ docker rmi --help

Usage:  docker rmi [OPTIONS] IMAGE [IMAGE...]

Remove one or more images

Options:
  -f, --force      Force removal of the image
      --no-prune   Do not delete untagged parents

# 使用镜像ID来删除
[hekai@localhost ~]$ docker rmi -f d54bd1054823
Untagged: mysql:5.7
Untagged: mysql@sha256:9fc60b229633ce1d1f2ee306705152d4b001056fb27c1b5debe23a732df72b70
Deleted: sha256:d54bd1054823adac521a08c227f8f7106e93158184f0978eda0eb6ab7b4a5b38
Deleted: sha256:81df52d6b6986ce243ecad13c5a33d6685cca38a7f246e275c20b459068ac8bc
Deleted: sha256:76c8845eec0bc7703e321f1f5a312033cb73d4bbea7212517cdfd84ef52f532d
Deleted: sha256:b851a484b18c5d3d25497260c111631ae3adf924eb10baa533b2a5b03b339d1a
Deleted: sha256:b5133b076285236e7fd98c42c1f18f57e2b4ed98daaed7b0afb3b98b804d6f25

# 删除所有镜像
[hekai@localhost ~]$ docker rmi -f d54bd1054823
# 有项目时谨慎操作,删除后没有镜像了
[hekai@localhost ~]$ docker images -a
REPOSITORY   TAG       IMAGE ID   CREATED   SIZE
[hekai@localhost ~]$

容器命令

说明:有了镜像才可以创建容器,linux,下载一个centos镜像来测试学习

[hekai@localhost ~]$ docker pull centos
Using default tag: latest
latest: Pulling from library/centos
7a0437f04f83: Pull complete
Digest: sha256:5528e8b1b1719d34604c87e11dcd1c0a20bedf46e83b5632cdeac91b8c04efc1
Status: Downloaded newer image for centos:latest
docker.io/library/centos:latest

新建容器并启动

docker run [可选参数] imageName

# 参数很多,详细的看--help说明
--name="Name"       容器名字(用于区分)
-d                  后台方式运行
-it                 使用交互方式运行,并进入容器查看内容
-p                  指定容器的端口  -p 8080:8080
    -p  ip:主机端口:容器端口
    -p  主机端口:容器端口(常用)
    -p  容器端口
-P                  随机指定端口(大写P)
# 运行centos
[hekai@localhost ~]$ docker run -it centos /bin/bash
[root@fe6c8790977f /]#
# 变为root@fe6c8790977f /了,表明进入centos系统了

# 退出容器,回到主机
[root@fe6c8790977f /]# exit
exit
[hekai@localhost ~]$ 

列出所有正在运行的容器

# docker ps命令
    # 列出当前运行的容器
-a  # 列出当前运行的容器+历史运行过的容器
-n=?    # 显示最近创建的容器
-q  # 只显示容器的ID

# 具体查看
[hekai@localhost ~]$ docker ps --help

Usage:  docker ps [OPTIONS]

List containers

Options:
  -a, --all             Show all containers (default shows just running)
  -f, --filter filter   Filter output based on conditions provided
      --format string   Pretty-print containers using a Go template
  -n, --last int        Show n last created containers (includes all states) (default -1)
  -l, --latest          Show the latest created container (includes all states)
      --no-trunc        Don't truncate output
  -q, --quiet           Only display container IDs
  -s, --size            Display total file sizes

# 使用
# 查看正在运行的容器
[hekai@localhost ~]$ docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[hekai@localhost ~]$
# 上面exit了,所以没有在运行的了

# 查看运行过的容器
[hekai@localhost ~]$ docker ps -a
CONTAINER ID   IMAGE          COMMAND       CREATED         STATUS                          PORTS     NAMES
fe6c8790977f   centos         "/bin/bash"   3 minutes ago   Exited (0) About a minute ago             xenodochial_rhodes
82b433f723cd   d1165f221234   "/hello"      21 hours ago    Exited (0) 21 hours ago                   romantic_herschel

退出容器

exit    # 容器直接停止并退出了
Ctrl+P+Q    # 容器不停止并退出

# 启动容器并使用Ctrl+P+Q退出
[hekai@localhost ~]$ docker run -it centos /bin/bash
[root@2b5761a51caf /]# [hekai@localhost ~]$

[hekai@localhost ~]$ docker ps
CONTAINER ID   IMAGE     COMMAND       CREATED          STATUS          PORTS     NAMES
2b5761a51caf   centos    "/bin/bash"   18 seconds ago   Up 18 seconds             dreamy_brahmagupta

删除容器

docker rm 容器id  # 删除指定容器
docker rm -f $(docker ps -aq)   # 删除所有容器
docker ps -a | xargs docker rm  # 删除所有容器
# 使用

# 首先查看历史容器运行情况
[hekai@localhost ~]$ docker ps -a
CONTAINER ID   IMAGE          COMMAND       CREATED          STATUS                      PORTS     NAMES
2b5761a51caf   centos         "/bin/bash"   2 minutes ago    Up 2 minutes                          dreamy_brahmagupta
fe6c8790977f   centos         "/bin/bash"   12 minutes ago   Exited (0) 11 minutes ago             xenodochial_rhodes
82b433f723cd   d1165f221234   "/hello"      21 hours ago     Exited (0) 21 hours ago               romantic_herschel

# 删除fe6c8790977f
[hekai@localhost ~]$ docker rm fe6c8790977f
fe6c8790977f
[hekai@localhost ~]$

# 删除2b5761a51caf
[hekai@localhost ~]$ docker rm 2b5761a51caf
Error response from daemon: You cannot remove a running container 2b5761a51cafa9c659b40807fc76df3198063c5592ad7d3d1aec7501d6f9d546. Stop the container before attempting removal or force remove
[hekai@localhost ~]$
# 会报错,因为在后台运行

# 使用docker rm -f $(docker ps -aq)删除所有容器
[hekai@localhost ~]$ docker rm -f $(docker ps -aq)
2b5761a51caf
82b433f723cd
[hekai@localhost ~]$

# 已经全部删除
[hekai@localhost ~]$ docker ps -a
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[hekai@localhost ~]$

启动和停止容器操作

docker start 容器id
docker restart 容器id
docker stop 容器id
docker kill 容器id

# docker start与docker stop的使用
[hekai@localhost ~]$ docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[hekai@localhost ~]$ docker ps -a
CONTAINER ID   IMAGE     COMMAND       CREATED          STATUS                     PORTS     NAMES
8beb48e73fc4   centos    "/bin/bash"   10 seconds ago   Exited (0) 7 seconds ago             objective_lovelace
[hekai@localhost ~]$ docker start 8beb48e73fc4
8beb48e73fc4
[hekai@localhost ~]$ docker ps
CONTAINER ID   IMAGE     COMMAND       CREATED          STATUS         PORTS     NAMES
8beb48e73fc4   centos    "/bin/bash"   35 seconds ago   Up 3 seconds             objective_lovelace
[hekai@localhost ~]$ docker stop 8beb48e73fc4
8beb48e73fc4
[hekai@localhost ~]$ docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES

常用其他命令

后台启动容器

# 命令docker run -d 镜像名
[hekai@localhost ~]$ docker run -d centos
dc8302e323d9458b1fd5953b4f3e85b62719cd449d9ecca664a878a9b3eccbfb
[hekai@localhost ~]$ docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[hekai@localhost ~]$

# docker ps发现centos停止了! 

# 常见的坑:docker容器后台运行,必须要有前台进程,没有就会停止
# 比如nginx,容器后台启动后,发现自己没有提供服务,就会立刻停止

查看日志

# 查看log最后10行
# 这个id对应的容器要运行着的有输出的容器
# docker logs -f -t --tail 10 容器id

# 这里写一个死循环演示
docker run -d centos /bin/bash -c "while true;do echo kuangshen;sleep 2;done"

[hekai@localhost ~]$ docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS     NAMES
91c8a4e888c2   centos    "/bin/bash -c 'while…"   6 seconds ago   Up 4 seconds             relaxed_kilby

# 显示日志
-tf             # 显示日志
--tail number   # 要显示的日志条数
[hekai@localhost ~]$ docker logs -tf --tail 10 91c8a4e888c2
2021-03-07T08:32:32.424353088Z kuangshen
2021-03-07T08:32:34.427269919Z kuangshen
2021-03-07T08:32:36.429872414Z kuangshen
2021-03-07T08:32:38.432673709Z kuangshen
2021-03-07T08:32:40.435887830Z kuangshen
2021-03-07T08:32:42.438803465Z kuangshen
2021-03-07T08:32:44.441780459Z kuangshen

进程命令

# 命令docker top 容器id
[hekai@localhost ~]$ docker top 91c8a4e888c2
UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
root                1485                1456                0                   16:32               ?                   00:00:00            /bin/bash -c while true;do echo kuangshen;sleep 2;done
root                3700                1485                0                   16:36               ?                   00:00:00            /usr/bin/coreutils --coreutils-prog-shebang=sleep /usr/bin/sleep 2

查看镜像的元数据

# 命令docker inspect 容器id
[hekai@localhost ~]$ docker inspect 91c8a4e888c2
[
    {
        "Id": "91c8a4e888c21ff161314e5e895cfac2e60f2bcf3fcaf35cf2af0b1705ba5a26",
        "Created": "2021-03-07T08:32:09.706013152Z",
        "Path": "/bin/bash",
        "Args": [
            "-c",
            "while true;do echo kuangshen;sleep 2;done"
        ],
        "State": {
            "Status": "running",
            "Running": true,
            "Paused": false,
            "Restarting": false,
            "OOMKilled": false,
            "Dead": false,
            "Pid": 1485,
            "ExitCode": 0,
            "Error": "",
            "StartedAt": "2021-03-07T08:32:10.389729529Z",
            "FinishedAt": "0001-01-01T00:00:00Z"
        },
        "Image": "sha256:300e315adb2f96afe5f0b2780b87f28ae95231fe3bdd1e16b9ba606307728f55",
        "ResolvConfPath": "/var/lib/docker/containers/91c8a4e888c21ff161314e5e895cfac2e60f2bcf3fcaf35cf2af0b1705ba5a26/resolv.conf",
        "HostnamePath": "/var/lib/docker/containers/91c8a4e888c21ff161314e5e895cfac2e60f2bcf3fcaf35cf2af0b1705ba5a26/hostname",
        "HostsPath": "/var/lib/docker/containers/91c8a4e888c21ff161314e5e895cfac2e60f2bcf3fcaf35cf2af0b1705ba5a26/hosts",
        "LogPath": "/var/lib/docker/containers/91c8a4e888c21ff161314e5e895cfac2e60f2bcf3fcaf35cf2af0b1705ba5a26/91c8a4e888c21ff161314e5e895cfac2e60f2bcf3fcaf35cf2af0b1705ba5a26-json.log"                 ,
        "Name": "/relaxed_kilby",
        "RestartCount": 0,
        "Driver": "overlay2",
        "Platform": "linux",
        "MountLabel": "",
        "ProcessLabel": "",
        "AppArmorProfile": "docker-default",
        "ExecIDs": null,
        "HostConfig": {
            "Binds": null,
            "ContainerIDFile": "",
            "LogConfig": {
                "Type": "json-file",
                "Config": {}
            },
            "NetworkMode": "default",
            "PortBindings": {},
            "RestartPolicy": {
                "Name": "no",
                "MaximumRetryCount": 0
            },
            "AutoRemove": false,
            "VolumeDriver": "",
            "VolumesFrom": null,
            "CapAdd": null,
            "CapDrop": null,
            "CgroupnsMode": "host",
            "Dns": [],
            "DnsOptions": [],
            "DnsSearch": [],
            "ExtraHosts": null,
            "GroupAdd": null,
            "IpcMode": "private",
            "Cgroup": "",
            "Links": null,
            "OomScoreAdj": 0,
            "PidMode": "",
            "Privileged": false,
            "PublishAllPorts": false,
            "ReadonlyRootfs": false,
            "SecurityOpt": null,
            "UTSMode": "",
            "UsernsMode": "",
            "ShmSize": 67108864,
            "Runtime": "runc",
            "ConsoleSize": [
                0,
                0
            ],
            "Isolation": "",
            "CpuShares": 0,
            "Memory": 0,
            "NanoCpus": 0,
            "CgroupParent": "",
            "BlkioWeight": 0,
            "BlkioWeightDevice": [],
            "BlkioDeviceReadBps": null,
            "BlkioDeviceWriteBps": null,
            "BlkioDeviceReadIOps": null,
            "BlkioDeviceWriteIOps": null,
            "CpuPeriod": 0,
            "CpuQuota": 0,
            "CpuRealtimePeriod": 0,
            "CpuRealtimeRuntime": 0,
            "CpusetCpus": "",
            "CpusetMems": "",
            "Devices": [],
            "DeviceCgroupRules": null,
            "DeviceRequests": null,
            "KernelMemory": 0,
            "KernelMemoryTCP": 0,
            "MemoryReservation": 0,
            "MemorySwap": 0,
            "MemorySwappiness": null,
            "OomKillDisable": false,
            "PidsLimit": null,
            "Ulimits": null,
            "CpuCount": 0,
            "CpuPercent": 0,
            "IOMaximumIOps": 0,
            "IOMaximumBandwidth": 0,
            "MaskedPaths": [
                "/proc/asound",
                "/proc/acpi",
                "/proc/kcore",
                "/proc/keys",
                "/proc/latency_stats",
                "/proc/timer_list",
                "/proc/timer_stats",
                "/proc/sched_debug",
                "/proc/scsi",
                "/sys/firmware"
            ],
            "ReadonlyPaths": [
                "/proc/bus",
                "/proc/fs",
                "/proc/irq",
                "/proc/sys",
                "/proc/sysrq-trigger"
            ]
        },
        "GraphDriver": {
            "Data": {
                "LowerDir": "/var/lib/docker/overlay2/167abb722868659ced56842f64195a313c1df979ab65eb054d4a8856ecab6467-init/diff:/var/lib/docker/overlay2/1db1c788013b606e98d68285613ce492                 71037dc780ba7121123b24ba72905877/diff",
                "MergedDir": "/var/lib/docker/overlay2/167abb722868659ced56842f64195a313c1df979ab65eb054d4a8856ecab6467/merged",
                "UpperDir": "/var/lib/docker/overlay2/167abb722868659ced56842f64195a313c1df979ab65eb054d4a8856ecab6467/diff",
                "WorkDir": "/var/lib/docker/overlay2/167abb722868659ced56842f64195a313c1df979ab65eb054d4a8856ecab6467/work"
            },
            "Name": "overlay2"
        },
        "Mounts": [],
        "Config": {
            "Hostname": "91c8a4e888c2",
            "Domainname": "",
            "User": "",
            "AttachStdin": false,
            "AttachStdout": false,
            "AttachStderr": false,
            "Tty": false,
            "OpenStdin": false,
            "StdinOnce": false,
            "Env": [
                "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
            ],
            "Cmd": [
                "/bin/bash",
                "-c",
                "while true;do echo kuangshen;sleep 2;done"
            ],
            "Image": "centos",
            "Volumes": null,
            "WorkingDir": "",
            "Entrypoint": null,
            "OnBuild": null,
            "Labels": {
                "org.label-schema.build-date": "20201204",
                "org.label-schema.license": "GPLv2",
                "org.label-schema.name": "CentOS Base Image",
                "org.label-schema.schema-version": "1.0",
                "org.label-schema.vendor": "CentOS"
            }
        },
        "NetworkSettings": {
            "Bridge": "",
            "SandboxID": "34258a3791a3fcd90ffd0841e627831f3c6d347a78e04bb9ef95780b67900da4",
            "HairpinMode": false,
            "LinkLocalIPv6Address": "",
            "LinkLocalIPv6PrefixLen": 0,
            "Ports": {},
            "SandboxKey": "/var/run/docker/netns/34258a3791a3",
            "SecondaryIPAddresses": null,
            "SecondaryIPv6Addresses": null,
            "EndpointID": "2de0d2e9babd0ae3692342fcc37e40504d364ef239ba0177024a686d099fe904",
            "Gateway": "172.17.0.1",
            "GlobalIPv6Address": "",
            "GlobalIPv6PrefixLen": 0,
            "IPAddress": "172.17.0.2",
            "IPPrefixLen": 16,
            "IPv6Gateway": "",
            "MacAddress": "02:42:ac:11:00:02",
            "Networks": {
                "bridge": {
                    "IPAMConfig": null,
                    "Links": null,
                    "Aliases": null,
                    "NetworkID": "1d62f1dd42f99e2215656458889ec868c208dfe4ac5fb9510b13185d218ec6c5",
                    "EndpointID": "2de0d2e9babd0ae3692342fcc37e40504d364ef239ba0177024a686d099fe904",
                    "Gateway": "172.17.0.1",
                    "IPAddress": "172.17.0.2",
                    "IPPrefixLen": 16,
                    "IPv6Gateway": "",
                    "GlobalIPv6Address": "",
                    "GlobalIPv6PrefixLen": 0,
                    "MacAddress": "02:42:ac:11:00:02",
                    "DriverOpts": null
                }
            }
        }
    }
]

进入当前运行的容器

# 容器通常是后台运行的,当要修改一些配置时,需要进入容器

# 方式一:docker exec -it 容器id
[hekai@localhost ~]$ docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED         STATUS         PORTS     NAMES
91c8a4e888c2   centos    "/bin/bash -c 'while…"   9 minutes ago   Up 9 minutes             relaxed_kilby
[hekai@localhost ~]$ docker exec -it 91c8a4e888c2 /bin/bash
[root@91c8a4e888c2 /]#

# 方式二:docker attach 容器id
[hekai@localhost ~]$ docker ps
CONTAINER ID   IMAGE     COMMAND                  CREATED          STATUS          PORTS     NAMES
91c8a4e888c2   centos    "/bin/bash -c 'while…"   12 minutes ago   Up 12 minutes             relaxed_kilby
[hekai@localhost ~]$ docker attach 91c8a4e888c2
kuangshen
kuangshen
kuangshen
kuangshen
# 然后进入那个循环中没法出来了,要重启终端!删除容器
[hekai@localhost ~]$ docker rm -f $(docker ps -aq)

两种方式进入容器的区别

docker exec     # 进入容器后开启一个新的终端,可以在里面操作(常用)
docker attach    # 进入容器正在执行的终端,不会启动新的进程!

从容器内拷贝文件到主机

# docker cp 容器id:容器内路径 目的主机路径

# 启动一个容器,然后Ctrl+P+Q不停止运行退出
[hekai@localhost ~]$ docker run -it centos /bin/bash
[root@1a6459ce2109 home]# cd home
[root@1a6459ce2109 home]# touch yinbinqiu.go
[root@1a6459ce2109 /]# exit

# 查看运行过的容器
[hekai@localhost test_local]$ docker ps -a
CONTAINER ID   IMAGE     COMMAND       CREATED         STATUS                     PORTS     NAMES
1a6459ce2109   centos    "/bin/bash"   7 minutes ago   Exited (0) 3 minutes ago             brave_antonelli

[hekai@localhost ~]$ mkdir /home/hekai/test_local
[hekai@localhost ~]$ docker cp 1a6459ce2109:/home/yinbinqiu.go /home/hekai/test_local
[hekai@localhost ~]$ cd /home/hekai/test_local
[hekai@localhost test_local]$ ls
yinbinqiu.go
[hekai@localhost test_local]$
# 成功将docker中的文件拷贝到本机!

# 这个例子是手动操作,后面可以使用 -v 卷的技术,自动同步文件夹

学习方式:按照视频将所有命令敲一遍,记录笔记!

参考:https://www.bilibili.com/video/BV1og4y1q7M4?p=12&spm_id_from=pageDriver


最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 214,658评论 6 496
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 91,482评论 3 389
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 160,213评论 0 350
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 57,395评论 1 288
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 66,487评论 6 386
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 50,523评论 1 293
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 39,525评论 3 414
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,300评论 0 270
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 44,753评论 1 307
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,048评论 2 330
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,223评论 1 343
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 34,905评论 5 338
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,541评论 3 322
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,168评论 0 21
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,417评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,094评论 2 365
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,088评论 2 352

推荐阅读更多精彩内容