尚硅谷Docker实战教程-笔记03【Docker常用命令】

news2024/11/16 1:44:14
  • 尚硅谷大数据技术-教程-学习路线-笔记汇总表【课程资料下载】
  • 视频地址:尚硅谷Docker实战教程(docker教程天花板)_哔哩哔哩_bilibili
  1. 尚硅谷Docker实战教程-笔记01【理念简介、官网介绍、平台入门图解、平台架构图解】
  2. 尚硅谷Docker实战教程-笔记02【安装docker、镜像加速器配置】
  3. 尚硅谷Docker实战教程-笔记03【Docker常用命令】
  4. 尚硅谷Docker实战教程-笔记04【Docker镜像】
  5. 尚硅谷Docker实战教程-笔记05【】

目录

1.基础篇

3.Docker常用命令

P015【15_帮助启动类命令】07:32

P016【16_镜像命令】22:56

P017【17_ubuntu容器说明】03:11

P018【18_容器命令A】16:30

P019【19_容器命令B】04:24

P020【20_容器命令C】10:36

P021【21_容器命令D】25:01

P022【22_容器命令E】09:15


1.基础篇

3.Docker常用命令

P015【15_帮助启动类命令】07:32

[root@node001 docker]# docker status docker
docker: 'status' is not a docker command.
See 'docker --help'
[root@node001 docker]# systemctl status docker
● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; disabled; vendor preset: disabled)
   Active: active (running) since 五 2023-05-26 15:14:55 CST; 17min ago
     Docs: https://docs.docker.com
 Main PID: 4160 (dockerd)
    Tasks: 11
   Memory: 30.2M
   CGroup: /system.slice/docker.service
           └─4160 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock

5月 26 15:14:54 node001 dockerd[4160]: time="2023-05-26T15:14:54.528872384+08:00" level=info msg="Starting up"
5月 26 15:14:54 node001 dockerd[4160]: time="2023-05-26T15:14:54.612128512+08:00" level=info msg="[graphdriver] using prior storage driver: overlay2"
5月 26 15:14:54 node001 dockerd[4160]: time="2023-05-26T15:14:54.613619570+08:00" level=info msg="Loading containers: start."
5月 26 15:14:55 node001 dockerd[4160]: time="2023-05-26T15:14:55.000236197+08:00" level=info msg="Default bridge (docker0) is assigned with an IP ... address"
5月 26 15:14:55 node001 dockerd[4160]: time="2023-05-26T15:14:55.128860025+08:00" level=info msg="Loading containers: done."
5月 26 15:14:55 node001 dockerd[4160]: time="2023-05-26T15:14:55.180968994+08:00" level=info msg="Docker daemon" commit=463850e graphdriver=overla...on=24.0.1
5月 26 15:14:55 node001 dockerd[4160]: time="2023-05-26T15:14:55.181125988+08:00" level=info msg="Daemon has completed initialization"
5月 26 15:14:55 node001 dockerd[4160]: time="2023-05-26T15:14:55.270751801+08:00" level=info msg="API listen on /run/docker.sock"
5月 26 15:14:55 node001 systemd[1]: Started Docker Application Container Engine.
5月 26 15:15:19 node001 dockerd[4160]: time="2023-05-26T15:15:19.315721290+08:00" level=info msg="ignoring event" container=3ff6498fa0a7d34b5995ac...skDelete"
Hint: Some lines were ellipsized, use -l to show in full.
[root@node001 docker]# docker --help

Usage:  docker [OPTIONS] COMMAND

A self-sufficient runtime for containers

Common Commands:
  run         Create and run a new container from an image
  exec        Execute a command in a running container
  ps          List containers
  build       Build an image from a Dockerfile
  pull        Download an image from a registry
  push        Upload an image to a registry
  images      List images
  login       Log in to a registry
  logout      Log out from a registry
  search      Search Docker Hub for images
  version     Show the Docker version information
  info        Display system-wide information

Management Commands:
  builder     Manage builds
  buildx*     Docker Buildx (Docker Inc., v0.10.4)
  compose*    Docker Compose (Docker Inc., v2.18.1)
  container   Manage containers
  context     Manage contexts
  image       Manage images
  manifest    Manage Docker image manifests and manifest lists
  network     Manage networks
  plugin      Manage plugins
  system      Manage Docker
  trust       Manage trust on Docker images
  volume      Manage volumes

Swarm Commands:
  swarm       Manage Swarm

Commands:
  attach      Attach local standard input, output, and error streams to a running container
  commit      Create a new image from a container's changes
  cp          Copy files/folders between a container and the local filesystem
  create      Create a new container
  diff        Inspect changes to files or directories on a container's filesystem
  events      Get real time events from the server
  export      Export a container's filesystem as a tar archive
  history     Show the history of an image
  import      Import the contents from a tarball to create a filesystem image
  inspect     Return low-level information on Docker objects
  kill        Kill one or more running containers
  load        Load an image from a tar archive or STDIN
  logs        Fetch the logs of a container
  pause       Pause all processes within one or more containers
  port        List port mappings or a specific mapping for the container
  rename      Rename a container
  restart     Restart one or more containers
  rm          Remove one or more containers
  rmi         Remove one or more images
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  start       Start one or more stopped containers
  stats       Display a live stream of container(s) resource usage statistics
  stop        Stop one or more running containers
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE
  top         Display the running processes of a container
  unpause     Unpause all processes within one or more containers
  update      Update configuration of one or more containers
  wait        Block until one or more containers stop, then print their exit codes

Global Options:
      --config string      Location of client config files (default "/root/.docker")
  -c, --context string     Name of the context to use to connect to the daemon (overrides DOCKER_HOST env var and default context set with "docker
                           context use")
  -D, --debug              Enable debug mode
  -H, --host list          Daemon socket to connect to
  -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 quit

Run 'docker COMMAND --help' for more information on a command.

For more help on how to use Docker, head to https://docs.docker.com/go/guides/
[root@node001 docker]# docker cp --help

Usage:  docker cp [OPTIONS] CONTAINER:SRC_PATH DEST_PATH|-
        docker cp [OPTIONS] SRC_PATH|- CONTAINER:DEST_PATH

Copy files/folders between a container and the local filesystem

Use '-' as the source to read a tar archive from stdin
and extract it to a directory destination in a container.
Use '-' as the destination to stream a tar archive of a
container source to stdout.

Aliases:
  docker container cp, docker cp

Options:
  -a, --archive       Archive mode (copy all uid/gid information)
  -L, --follow-link   Always follow symbol link in SRC_PATH
  -q, --quiet         Suppress progress output during copy. Progress output is automatically suppressed if no terminal is attached
[root@node001 docker]# 
[root@node001 atguigu]# man docker-run
[root@node001 atguigu]# 

P016【16_镜像命令】22:56

[root@node001 atguigu]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED       SIZE
hello-world   latest    9c7a54a9a43c   7 weeks ago   13.3kB
[root@node001 atguigu]# docker image is

Usage:  docker image COMMAND

Manage images

Commands:
  build       Build an image from a Dockerfile
  history     Show the history of an image
  import      Import the contents from a tarball to create a filesystem image
  inspect     Display detailed information on one or more images
  load        Load an image from a tar archive or STDIN
  ls          List images
  prune       Remove unused images
  pull        Download an image from a registry
  push        Upload an image to a registry
  rm          Remove one or more images
  save        Save one or more images to a tar archive (streamed to STDOUT by default)
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE

Run 'docker image COMMAND --help' for more information on a command.
[root@node001 atguigu]# docker search hello-world
NAME                                       DESCRIPTION                                      STARS     OFFICIAL   AUTOMATED
hello-world                                Hello World! (an example of minimal Dockeriz…   2051      [OK]       
rancher/hello-world                                                                         4                    
okteto/hello-world                                                                          0                    
golift/hello-world                         Hello World Go-App built by Go Lift Applicat…   0                    
tacc/hello-world                                                                            0                    
armswdev/c-hello-world                     Simple hello-world C program on Alpine Linux…   0                    
tutum/hello-world                          Image to test docker deployments. Has Apache…   90                   [OK]
thomaspoignant/hello-world-rest-json       This project is a REST hello-world API to bu…   2                    
kitematic/hello-world-nginx                A light-weight nginx container that demonstr…   152                  
dockercloud/hello-world                    Hello World!                                     20                   [OK]
ansibleplaybookbundle/hello-world-apb      An APB which deploys a sample Hello World! a…   1                    [OK]
ansibleplaybookbundle/hello-world-db-apb   An APB which deploys a sample Hello World! a…   2                    [OK]
crccheck/hello-world                       Hello World web server in under 2.5 MB           17                   [OK]
strimzi/hello-world-consumer                                                                0                    
strimzi/hello-world-producer                                                                0                    
businessgeeks00/hello-world-nodejs                                                          0                    
koudaiii/hello-world                                                                        0                    
freddiedevops/hello-world-spring-boot                                                       0                    
strimzi/hello-world-streams                                                                 0                    
garystafford/hello-world                   Simple hello-world Spring Boot service for t…   0                    [OK]
ppc64le/hello-world                        Hello World! (an example of minimal Dockeriz…   2                    
tsepotesting123/hello-world                                                                 0                    
kevindockercompany/hello-world                                                              0                    
dandando/hello-world-dotnet                                                                 0                    
vad1mo/hello-world-rest                    A simple REST Service that echoes back all t…   7                    [OK]
[root@node001 atguigu]# docker search mysql
NAME                            DESCRIPTION                                      STARS     OFFICIAL   AUTOMATED
mysql                           MySQL is a widely used, open-source relation…   14263     [OK]       
mariadb                         MariaDB Server is a high performing open sou…   5453      [OK]       
percona                         Percona Server is a fork of the MySQL relati…   616       [OK]       
phpmyadmin                      phpMyAdmin - A web interface for MySQL and M…   829       [OK]       
bitnami/mysql                   Bitnami MySQL Docker Image                       90                   [OK]
circleci/mysql                  MySQL is a widely used, open-source relation…   29                   
bitnami/mysqld-exporter                                                          5                    
ubuntu/mysql                    MySQL open source fast, stable, multi-thread…   51                   
cimg/mysql                                                                       0                    
rapidfort/mysql                 RapidFort optimized, hardened image for MySQL    23                   
rapidfort/mysql8-ib             RapidFort optimized, hardened image for MySQ…   9                    
google/mysql                    MySQL server for Google Compute Engine           23                   [OK]
hashicorp/mysql-portworx-demo                                                    0                    
rapidfort/mysql-official        RapidFort optimized, hardened image for MySQ…   7                    
newrelic/mysql-plugin           New Relic Plugin for monitoring MySQL databa…   1                    [OK]
databack/mysql-backup           Back up mysql databases to... anywhere!          86                   
bitnamicharts/mysql                                                              0                    
linuxserver/mysql               A Mysql container, brought to you by LinuxSe…   38                   
mirantis/mysql                                                                   0                    
docksal/mysql                   MySQL service images for Docksal - https://d…   0                    
linuxserver/mysql-workbench                                                      50                   
vitess/mysqlctld                vitess/mysqlctld                                 1                    [OK]
eclipse/mysql                   Mysql 5.7, curl, rsync                           0                    [OK]
drupalci/mysql-5.5              https://www.drupal.org/project/drupalci          3                    [OK]
drupalci/mysql-5.7              https://www.drupal.org/project/drupalci          0                    
[root@node001 atguigu]# docker search minio
NAME                           DESCRIPTION                                      STARS     OFFICIAL   AUTOMATED
bitnami/minio                  Bitnami MinIO Docker Image                       95                   
bitnami/minio-client           Bitnami MinIO Client Docker Image                11                   
rancher/minio-minio                                                             1                    
bitnamicharts/minio                                                             0                    
corpusops/minio                https://github.com/corpusops/docker-images/      0                    
longhornio/minio                                                                0                    
drud/minio                                                                      0                    
hephy/minio                                                                     0                    
silintl/minio-default-server                                                    0                    
corpusops/minio-k8s-operator   https://github.com/corpusops/docker-images/      0                    
corpusops/minio-mint           https://github.com/corpusops/docker-images/      0                    
newrelic/synthetics-minion     Synthetics Containerized Private Minion          5                    
corpusops/minio-doctor         https://github.com/corpusops/docker-images/      0                    
drud/minio-exporter                                                             0                    
vulhub/minio                                                                    0                    
jumpserver/minio               Multi-Cloud Object Storage                       0                    
minio/minio                    Multi-Cloud Object Storage                       723                  [OK]
minio/mc                       Minio Client (mc) provides a modern alternat…   41                   [OK]
minio/console                  A graphical user interface for MinIO server      15                   
jumpserver/mc                  Minio Client (mc) provides a modern alternat…   0                    
minio/k8s-operator             Minio Operator for k8s https://kubernetes.io/    1                    
minio/operator                                                                  3                    
minio/kes                      Description  Kes is a tool for managing and …   2                    
minio/direct-csi               Container Storage Interface (CSI) driver for…   0                    
minio/logsearchapi                                                              2                    
[root@node001 atguigu]# docker search redis
NAME                                DESCRIPTION                                      STARS     OFFICIAL   AUTOMATED
redis                               Redis is an open source key-value store that…   12181     [OK]       
redislabs/redisearch                Redis With the RedisSearch module pre-loaded…   56                   
redislabs/redisinsight              RedisInsight - The GUI for Redis                 88                   
redislabs/rebloom                   A probablistic datatypes module for Redis        23                   [OK]
redislabs/redis                     Clustered in-memory database engine compatib…   38                   
redis/redis-stack-server            redis-stack-server installs a Redis server w…   45                   
redislabs/rejson                    RedisJSON - Enhanced JSON data type processi…   53                   
redis/redis-stack                   redis-stack installs a Redis server with add…   54                   
redislabs/redisgraph                A graph database module for Redis                26                   [OK]
redislabs/redismod                  An automated build of redismod - latest Redi…   41                   [OK]
redislabs/redistimeseries           A time series database module for Redis          12                   
redislabs/operator                                                                   7                    
redislabs/operator-internal         This repository contains pre-released versio…   1                    
redislabs/redis-py                                                                   5                    
redislabs/redis-webcli              A tiny Flask app to provide access to Redis …   3                    [OK]
redislabs/redisgears                An automated build of RedisGears                 4                    
redislabs/k8s-controller-internal                                                    0                    
redislabs/memtier_benchmark         Docker image to run memtier_benchmark            0                    
redislabs/ng-redis-raft             Redis with redis raft module                     0                    
redislabs/k8s-controller                                                             2                    
redislabs/redisai                                                                    5                    
redislabs/olmtest                   Test artefact for OLM CSV                        0                    
bitnami/redis                       Bitnami Redis Docker Image                       259                  [OK]
redislabs/olm-bundle                                                                 0                    
redislabs/redisml                   A Redis module that implements several machi…   3                    [OK]
[root@node001 atguigu]# docker search --limit  redis
invalid argument "redis" for "--limit" flag: strconv.ParseInt: parsing "redis": invalid syntax
See 'docker search --help'.
[root@node001 atguigu]# docker search --limit 5 redis
NAME                     DESCRIPTION                                      STARS     OFFICIAL   AUTOMATED
redis                    Redis is an open source key-value store that…   12181     [OK]       
redislabs/redisearch     Redis With the RedisSearch module pre-loaded…   56                   
redislabs/redisinsight   RedisInsight - The GUI for Redis                 88                   
redislabs/rebloom        A probablistic datatypes module for Redis        23                   [OK]
redislabs/redis          Clustered in-memory database engine compatib…   38                   
[root@node001 atguigu]# docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
2db29710123e: Pull complete 
Digest: sha256:2498fce14358aa50ead0cc6c19990fc6ff866ce72aeb5546e1d59caac3d0d60f
Status: Downloaded newer image for hello-world:latest
docker.io/library/hello-world:latest
[root@node001 atguigu]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
hello-world   <none>    9c7a54a9a43c   7 weeks ago     13.3kB
hello-world   latest    feb5d9fea6a5   21 months ago   13.3kB
[root@node001 atguigu]# docker pull ubuntu
Using default tag: latest
latest: Pulling from library/ubuntu
7b1a6ab2e44d: Pull complete 
Digest: sha256:626ffe58f6e7566e00254b638eb7e0f3b11d4da9675088f4781a50ae288f3322
Status: Downloaded newer image for ubuntu:latest
docker.io/library/ubuntu:latest
[root@node001 atguigu]# docker pull redis:6.8.0
Error response from daemon: manifest for redis:6.8.0 not found: manifest unknown: manifest unknown
[root@node001 atguigu]# docker pull redis:6.0.8
6.0.8: Pulling from library/redis
bb79b6b2107f: Pull complete 
1ed3521a5dcb: Pull complete 
5999b99cee8f: Pull complete 
3f806f5245c9: Pull complete 
f8a4497572b2: Pull complete 
eafe3b6b8d06: Pull complete 
Digest: sha256:21db12e5ab3cc343e9376d655e8eabbdbe5516801373e95a8a9e66010c5b8819
Status: Downloaded newer image for redis:6.0.8
docker.io/library/redis:6.0.8
[root@node001 atguigu]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
hello-world   <none>    9c7a54a9a43c   7 weeks ago     13.3kB
ubuntu        latest    ba6acccedd29   20 months ago   72.8MB
hello-world   latest    feb5d9fea6a5   21 months ago   13.3kB
redis         6.0.8     16ecd2772934   2 years ago     104MB
[root@node001 atguigu]# docker images -a
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
hello-world   <none>    9c7a54a9a43c   7 weeks ago     13.3kB
ubuntu        latest    ba6acccedd29   20 months ago   72.8MB
hello-world   latest    feb5d9fea6a5   21 months ago   13.3kB
redis         6.0.8     16ecd2772934   2 years ago     104MB
[root@node001 atguigu]# docker images -q
9c7a54a9a43c
ba6acccedd29
feb5d9fea6a5
16ecd2772934
[root@node001 atguigu]# df -h
文件系统                 容量  已用  可用 已用% 挂载点
/dev/mapper/centos-root   45G   26G   17G   62% /
devtmpfs                 2.0G     0  2.0G    0% /dev
tmpfs                    2.0G     0  2.0G    0% /dev/shm
tmpfs                    2.0G   13M  2.0G    1% /run
tmpfs                    2.0G     0  2.0G    0% /sys/fs/cgroup
/dev/sda1                976M  127M  782M   14% /boot
tmpfs                    394M   12K  394M    1% /run/user/42
tmpfs                    394M     0  394M    0% /run/user/1001
tmpfs                    394M     0  394M    0% /run/user/0
[root@node001 atguigu]# docker system df
TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          4         1         177MB     177MB (99%)
Containers      2         0         0B        0B
Local Volumes   0         0         0B        0B
Build Cache     0         0         0B        0B
[root@node001 atguigu]# docker rmi 16ecd2772934
Untagged: redis:6.0.8
Untagged: redis@sha256:21db12e5ab3cc343e9376d655e8eabbdbe5516801373e95a8a9e66010c5b8819
Deleted: sha256:16ecd277293476392b71021cdd585c40ad68f4a7488752eede95928735e39df4
Deleted: sha256:3746030fff867eb26a0338ad9d3ab832e6c19c7dc008090bcfa95c7b9f16f505
Deleted: sha256:1274ec54ad17d15ec95d2180cb1f791057e86dfcdfcc18cd58610a920e145945
Deleted: sha256:18d156147e54edec9a927080fdc0a53c4a8814b0c717b36dc62e637363c1a98d
Deleted: sha256:a8f09c4919857128b1466cc26381de0f9d39a94171534f63859a662d50c396ca
Deleted: sha256:2ae5fa95c0fce5ef33fbb87a7e2f49f2a56064566a37a83b97d3f668c10b43d6
Deleted: sha256:d0fe97fa8b8cefdffcef1d62b65aba51a6c87b6679628a2b50fc6a7a579f764c
[root@node001 atguigu]# docker images -a
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
hello-world   <none>    9c7a54a9a43c   7 weeks ago     13.3kB
ubuntu        latest    ba6acccedd29   20 months ago   72.8MB
hello-world   latest    feb5d9fea6a5   21 months ago   13.3kB
[root@node001 atguigu]# docker pull redis:6.0.8
6.0.8: Pulling from library/redis
bb79b6b2107f: Pull complete 
1ed3521a5dcb: Pull complete 
5999b99cee8f: Pull complete 
3f806f5245c9: Pull complete 
f8a4497572b2: Pull complete 
eafe3b6b8d06: Pull complete 
Digest: sha256:21db12e5ab3cc343e9376d655e8eabbdbe5516801373e95a8a9e66010c5b8819
Status: Downloaded newer image for redis:6.0.8
docker.io/library/redis:6.0.8
[root@node001 atguigu]# docker images -qa
9c7a54a9a43c
ba6acccedd29
feb5d9fea6a5
16ecd2772934
[root@node001 atguigu]# history 

P017【17_ubuntu容器说明】03:11

[root@node001 atguigu]# docker images -a
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
hello-world   <none>    9c7a54a9a43c   7 weeks ago     13.3kB
ubuntu        latest    ba6acccedd29   20 months ago   72.8MB
hello-world   latest    feb5d9fea6a5   21 months ago   13.3kB
redis         6.0.8     16ecd2772934   2 years ago     104MB
[root@node001 atguigu]# 

P018【18_容器命令A】16:30

i interactive
t tyy
shell交互命令的接口

[root@node001 ~]# docker images
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
hello-world   <none>    9c7a54a9a43c   7 weeks ago     13.3kB
ubuntu        latest    ba6acccedd29   20 months ago   72.8MB
hello-world   latest    feb5d9fea6a5   21 months ago   13.3kB
redis         6.0.8     16ecd2772934   2 years ago     104MB
[root@node001 ~]# docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

[root@node001 ~]# docker run ubuntu
[root@node001 ~]# docker run -it ubuntu /bin/bash
root@a37594fd6c7e:/# ps -ef
UID         PID   PPID  C STIME TTY          TIME CMD
root          1      0  1 11:40 pts/0    00:00:00 /bin/bash
root          9      1  0 11:40 pts/0    00:00:00 ps -ef
root@a37594fd6c7e:/# ls
bin  boot  dev  etc  home  lib  lib32  lib64  libx32  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var
root@a37594fd6c7e:/# exit
exit
[root@node001 ~]# docker run -it ubuntu /bin/bash
root@8342de29884a:/# 
[root@node001 ~]# docker ps
CONTAINER ID   IMAGE     COMMAND       CREATED         STATUS         PORTS     NAMES
a37594fd6c7e   ubuntu    "/bin/bash"   2 minutes ago   Up 2 minutes             zealous_swirles
[root@node001 ~]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[root@node001 ~]# docker run -it --name=myu1 ubuntu bash
root@6c0111214702:/# 
[root@node001 ~]# docker ps
CONTAINER ID   IMAGE     COMMAND       CREATED          STATUS          PORTS     NAMES
6c0111214702   ubuntu    "bash"        9 seconds ago    Up 8 seconds              myu1
8342de29884a   ubuntu    "/bin/bash"   36 seconds ago   Up 35 seconds             determined_keldysh
[root@node001 ~]# 

P019【19_容器命令B】04:24

OPTIONS说明(常用):

  1. -a:列出当前所有正在运行的容器+历史上运行过的。
  2. -l:显示最近创建的容器。
  3. -n:显示最近n个创建的容器。
  4. -q:静默模式,只显示容器编号。
[root@node001 ~]# docker ps
CONTAINER ID   IMAGE     COMMAND   CREATED   STATUS    PORTS     NAMES
[root@node001 ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND       CREATED          STATUS                       PORTS     NAMES
6c0111214702   ubuntu         "bash"        15 minutes ago   Exited (129) 7 minutes ago             myu1
8342de29884a   ubuntu         "/bin/bash"   15 minutes ago   Exited (0) 7 minutes ago               determined_keldysh
a37594fd6c7e   ubuntu         "/bin/bash"   24 minutes ago   Exited (0) 16 minutes ago              zealous_swirles
cccf6112cf2f   ubuntu         "bash"        24 minutes ago   Exited (0) 24 minutes ago              eager_grothendieck
b09066c13913   hello-world    "/hello"      40 minutes ago   Exited (0) 40 minutes ago              unruffled_sinoussi
3ff6498fa0a7   9c7a54a9a43c   "/hello"      4 weeks ago      Exited (0) 4 weeks ago                 vigorous_mcnulty
7b023b885d8c   9c7a54a9a43c   "/hello"      4 weeks ago      Exited (0) 4 weeks ago                 gallant_lehmann
[root@node001 ~]# docker ps -l
CONTAINER ID   IMAGE     COMMAND   CREATED          STATUS                       PORTS     NAMES
6c0111214702   ubuntu    "bash"    15 minutes ago   Exited (129) 8 minutes ago             myu1
[root@node001 ~]# 

P020【20_容器命令C】10:36

P021【21_容器命令D】25:01

[root@node001 ~]# docker top angry_lewin
UID                 PID                 PPID                C                   STIME               TTY                 TIME                CMD
polkitd             76461               76441               0                   20:55               ?                   00:00:01            redis-server *:6379
[root@node001 ~]# docker exec -it angry_lewin /bin/bash
root@3fdf86ecd5d1:/data# redis-cli -p 6379
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set k1 v1
OK
127.0.0.1:6379> get k1
"v1"
127.0.0.1:6379> 

P022【22_容器命令E】09:15

[root@node001 ~]# docker ps
CONTAINER ID   IMAGE         COMMAND                   CREATED          STATUS          PORTS      NAMES
3fdf86ecd5d1   redis:6.0.8   "docker-entrypoint.s…"   51 minutes ago   Up 51 minutes   6379/tcp   angry_lewin
[root@node001 ~]# docker run -it ubuntu /bin/bash
root@438af94a059d:/# [root@node001 ~]# 
[root@node001 ~]# 
[root@node001 ~]# docker ps
CONTAINER ID   IMAGE         COMMAND                   CREATED          STATUS          PORTS      NAMES
438af94a059d   ubuntu        "/bin/bash"               7 seconds ago    Up 6 seconds               reverent_poitras
3fdf86ecd5d1   redis:6.0.8   "docker-entrypoint.s…"   52 minutes ago   Up 52 minutes   6379/tcp   angry_lewin
[root@node001 ~]# docker exec -it reverent_poitras /bin/bash
root@438af94a059d:/# pwd
/
root@438af94a059d:/# ll
total 56
drwxr-xr-x   1 root root 4096 Jun 29 13:46 ./
drwxr-xr-x   1 root root 4096 Jun 29 13:46 ../
-rwxr-xr-x   1 root root    0 Jun 29 13:46 .dockerenv*
lrwxrwxrwx   1 root root    7 Oct  6  2021 bin -> usr/bin/
drwxr-xr-x   2 root root 4096 Apr 15  2020 boot/
drwxr-xr-x   5 root root  360 Jun 29 13:46 dev/
drwxr-xr-x   1 root root 4096 Jun 29 13:46 etc/
drwxr-xr-x   2 root root 4096 Apr 15  2020 home/
lrwxrwxrwx   1 root root    7 Oct  6  2021 lib -> usr/lib/
lrwxrwxrwx   1 root root    9 Oct  6  2021 lib32 -> usr/lib32/
lrwxrwxrwx   1 root root    9 Oct  6  2021 lib64 -> usr/lib64/
lrwxrwxrwx   1 root root   10 Oct  6  2021 libx32 -> usr/libx32/
drwxr-xr-x   2 root root 4096 Oct  6  2021 media/
drwxr-xr-x   2 root root 4096 Oct  6  2021 mnt/
drwxr-xr-x   2 root root 4096 Oct  6  2021 opt/
dr-xr-xr-x 215 root root    0 Jun 29 13:46 proc/
drwx------   2 root root 4096 Oct  6  2021 root/
drwxr-xr-x   5 root root 4096 Oct  6  2021 run/
lrwxrwxrwx   1 root root    8 Oct  6  2021 sbin -> usr/sbin/
drwxr-xr-x   2 root root 4096 Oct  6  2021 srv/
dr-xr-xr-x  13 root root    0 Jun 29 13:46 sys/
drwxrwxrwt   2 root root 4096 Oct  6  2021 tmp/
drwxr-xr-x  13 root root 4096 Oct  6  2021 usr/
drwxr-xr-x  11 root root 4096 Oct  6  2021 var/
root@438af94a059d:/# cd tmp/
root@438af94a059d:/tmp# pwd
/tmp
root@438af94a059d:/tmp# touch a.txt
root@438af94a059d:/tmp# ll
total 8
drwxrwxrwt 1 root root 4096 Jun 29 13:48 ./
drwxr-xr-x 1 root root 4096 Jun 29 13:46 ../
-rw-r--r-- 1 root root    0 Jun 29 13:48 a.txt
root@438af94a059d:/tmp# read escape sequence
[root@node001 ~]# docker ps
CONTAINER ID   IMAGE         COMMAND                   CREATED          STATUS          PORTS      NAMES
438af94a059d   ubuntu        "/bin/bash"               5 minutes ago    Up 5 minutes               reverent_poitras
3fdf86ecd5d1   redis:6.0.8   "docker-entrypoint.s…"   57 minutes ago   Up 57 minutes   6379/tcp   angry_lewin
[root@node001 ~]# docker cp 438af94a059d:/tmp/a.txt /opt/data
                                               Successfully copied 1.54kB to /opt/data
[root@node001 ~]# 
[root@node001 ~]# docker ps
CONTAINER ID   IMAGE         COMMAND                   CREATED             STATUS             PORTS      NAMES
438af94a059d   ubuntu        "/bin/bash"               8 minutes ago       Up 8 minutes                  reverent_poitras
3fdf86ecd5d1   redis:6.0.8   "docker-entrypoint.s…"   About an hour ago   Up About an hour   6379/tcp   angry_lewin
[root@node001 ~]# docker export 438af94a059d > /opt/docker/test001.tar
[root@node001 ~]# docker rm-f 438af94a059d
docker: 'rm-f' is not a docker command.
See 'docker --help'
[root@node001 ~]# docker rm -f 438af94a059d
438af94a059d
[root@node001 ~]# docker ps
CONTAINER ID   IMAGE         COMMAND                   CREATED             STATUS             PORTS      NAMES
3fdf86ecd5d1   redis:6.0.8   "docker-entrypoint.s…"   About an hour ago   Up About an hour   6379/tcp   angry_lewin
[root@node001 ~]# cd /opt/docker/
[root@node001 docker]# ll
总用量 73404
-rw-r--r-- 1 root root 75158016 6月  29 21:57 test001.tar
[root@node001 docker]# cd ../
[root@node001 opt]# cat docker/test001.tar | docker import - atguigu/ubuntu:3.7
sha256:7b40f602c17835d8c9fc8315da7e8080b0e7d374b6e60be261d35315487647ef
[root@node001 opt]# docker ps
CONTAINER ID   IMAGE         COMMAND                   CREATED             STATUS             PORTS      NAMES
3fdf86ecd5d1   redis:6.0.8   "docker-entrypoint.s…"   About an hour ago   Up About an hour   6379/tcp   angry_lewin
[root@node001 opt]# docker images
REPOSITORY       TAG       IMAGE ID       CREATED          SIZE
atguigu/ubuntu   3.7       7b40f602c178   22 seconds ago   72.8MB
hello-world      <none>    9c7a54a9a43c   7 weeks ago      13.3kB
ubuntu           latest    ba6acccedd29   20 months ago    72.8MB
hello-world      latest    feb5d9fea6a5   21 months ago    13.3kB
redis            6.0.8     16ecd2772934   2 years ago      104MB
[root@node001 opt]# docker run -it 7b40f602c178 /bin/bash
root@70f68fe327a6:/# cd tmp/
root@70f68fe327a6:/tmp# ll
total 8
drwxrwxrwt 2 root root 4096 Jun 29 13:48 ./
drwxr-xr-x 1 root root 4096 Jun 29 14:01 ../
-rw-r--r-- 1 root root    0 Jun 29 13:48 a.txt
root@70f68fe327a6:/tmp# 

  1. attach    Attach to a running container                 # 当前 shell 下 attach 连接指定运行镜像
  2. build     Build an image from a Dockerfile              # 通过 Dockerfile 定制镜像
  3. commit    Create a new image from a container changes   # 提交当前容器为新的镜像
  4. cp        Copy files/folders from the containers filesystem to the host path   #从容器中拷贝指定文件或者目录到宿主机中
  5. create    Create a new container                        # 创建一个新的容器,同 run,但不启动容器
  6. diff      Inspect changes on a container's filesystem   # 查看 docker 容器变化
  7. events    Get real time events from the server          # 从 docker 服务获取容器实时事件
  8. exec      Run a command in an existing container        # 在已存在的容器上运行命令
  9. export    Stream the contents of a container as a tar archive   # 导出容器的内容流作为一个 tar 归档文件[对应 import ]
  10. history   Show the history of an image                  # 展示一个镜像形成历史
  11. images    List images                                   # 列出系统当前镜像
  12. import    Create a new filesystem image from the contents of a tarball # 从tar包中的内容创建一个新的文件系统映像[对应export]
  13. info      Display system-wide information               # 显示系统相关信息
  14. inspect   Return low-level information on a container   # 查看容器详细信息
  15. kill      Kill a running container                      # kill 指定 docker 容器
  16. load      Load an image from a tar archive              # 从一个 tar 包中加载一个镜像[对应 save]
  17. login     Register or Login to the docker registry server    # 注册或者登陆一个 docker 源服务器
  18. logout    Log out from a Docker registry server          # 从当前 Docker registry 退出
  19. logs      Fetch the logs of a container                 # 输出当前容器日志信息
  20. port      Lookup the public-facing port which is NAT-ed to PRIVATE_PORT    # 查看映射端口对应的容器内部源端口
  21. pause     Pause all processes within a container        # 暂停容器
  22. ps        List containers                               # 列出容器列表
  23. pull      Pull an image or a repository from the docker registry server   # 从docker镜像源服务器拉取指定镜像或者库镜像
  24. push      Push an image or a repository to the docker registry server    # 推送指定镜像或者库镜像至docker源服务器
  25. restart   Restart a running container                   # 重启运行的容器
  26. rm        Remove one or more containers                 # 移除一个或者多个容器
  27. rmi       Remove one or more images       # 移除一个或多个镜像[无容器使用该镜像才可删除,否则需删除相关容器才可继续或 -f 强制删除]
  28. run       Run a command in a new container              # 创建一个新的容器并运行一个命令
  29. save      Save an image to a tar archive                # 保存一个镜像为一个 tar 包[对应 load]
  30. search    Search for an image on the Docker Hub         # 在 docker hub 中搜索镜像
  31. start     Start a stopped containers                    # 启动容器
  32. stop      Stop a running containers                     # 停止容器
  33. tag       Tag an image into a repository                # 给源中镜像打标签
  34. top       Lookup the running processes of a container   # 查看容器中运行的进程信息
  35. unpause   Unpause a paused container                    # 取消暂停容器
  36. version   Show the docker version information           # 查看 docker 版本号
  37. wait      Block until a container stops, then print its exit code   # 截取容器停止时的退出状态值

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/700965.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Vue+G6搭建力导向图

1 效果 初始化时节点向中间聚拢 拖动后&#xff0c;随引力作用缓缓向中间聚拢 点击节点&#xff0c;节点放大&#xff0c;并展示标签文字 2 代码分析 2.1 数据 2.1.1 节点数据 nodes: [{id: 0,label: 0,value: 10,cluster: a,description: this is node 0, \nand the value…

帆软数据填报——多字段联合校验数据是否重复

功能&#xff1a;同一张表中&#xff0c;在填报时&#xff0c;设定多个字段联合维度下&#xff0c;记录不允许出现2条及以上 EG&#xff1a;同个项目同个时间维度不允许存在2条及以上的记录 效果&#xff1a; 说明&#xff1a;如果设定“管理项目编码”和“统计截止日期”字段…

【树莓派】解密树莓派Python项目中神秘的导入错误

文章目录 问题导入python文件目录分析解决方案 问题导入 小编在使用树莓派编写python项目时出现了以下两种错误&#xff1a; ModuleNotFoundError : No module named Motor from ..hardware.motor import Motor portError: attempted relative import with no known parent p…

【C语言】手把手带你解决青蛙跳台阶问题

君兮_的个人主页 勤时当勉励 岁月不待人 C/C 游戏开发 Hello,这里是君兮_&#xff0c;今天更新的是经典递归问题——青蛙跳台阶&#xff0c;在所有有关递归的问题中&#xff0c;青蛙跳台阶是最广为人知的问题之一&#xff0c;可以说&#xff0c;如果你能真正弄懂青蛙跳台阶问…

javaweb学习2

p标签使用 <!DOCTYPE html> <html lang"en"> <head><meta charset"UTF-8"><title>Title</title> </head> <body> <!--p标签定义段落 p元素自动在其前后创建一段空白--> hello&#xff0c;world &l…

电脑鼠标怎么改变形状

电脑鼠标怎么改变形状? 首先你要下载一个鼠标指针包&#xff0c;网上有很多这样的资源&#xff0c;选择你喜欢的那一个指针包。 点击开始菜单&#xff0c;找到控制面板&#xff0c;打开控制面板。 从控制面板里点击“硬件和声音”&#xff0c;在设备和打印机里面点击“鼠标”。…

1-Eureka服务注册与发现以及Eureka集群搭建(实操型)

1-Eureka服务注册与发现以及Eureka集群搭建&#xff08;实操型&#xff09; 1. 简单搭建微服务框架1.1 idea创建maven多模块项目1.2 项目结构1.3 项目依赖与配置1.3.1 父工程&#xff1a;dog-cloud-parent1.3.2 管理实体项目&#xff1a;dog-po1.3.3 服务提供者&#xff1a;dog…

HBase(9):过滤器

1 简介 在HBase中,如果要对海量的数据来进行查询,此时基本的操作是比较无力的。此时,需要借助HBase中的高级语法——Filter来进行查询。Filter可以根据列簇、列、版本等条件来对数据进行过滤查询。因为在HBase中,主键、列、版本都是有序存储的,所以借助Filter,可以高效地…

主流开源深度学习框架简介

主流开源深度学习框架简介 本文目录&#xff1a; 一、TensorFlow深度学习框架 二、PyTorch深度学习框架 三、Keras深度学习框架 四、Caffe深度学习框架 五、中国深度学习开源框架状况 六、几种框架的对比 七、其他统计数据 当下&#xff0c;有许多主流的开源深度学习框架…

mysql 模糊查询的字段 支持不区分大小写功能

1. 直接修改字段对应的校对规则即可 ​​​​​​ 2. 校对规则说明 ​ utf8_bin 将字符串中的每一个字符用二进制数据存储&#xff0c;区分大小写。 utf8_genera_ci 不区分大小写&#xff0c;ci为case insensitive的缩写&#xff0c;即大小写不敏感。utf8_general_cs 区分…

香蕉派BPI-R4 Wifi7路由器采用联发科MT7988A (Filogic 880)设计

香蕉派BPI-R4路由器板采用联发科MT7988A (Filogic 880)四核ARM Corex-A73方案设计&#xff0c;板载4GB DDR4内存,8GB eMMC存储,128MB SPI-NAND闪存&#xff0c;还具有2个10Gbe SFP光电口, 4x Gbe千兆网口&#xff0c;带USB3.2端口&#xff0c;M.2接口支持4G/5G/NVME SSD.2x min…

海外版“咸鱼”Carousell是什么?

做跨境的都知道&#xff0c;一定不能只在一颗树上吊死&#xff0c;潮流总是把你推着向前的&#xff0c;现在跨境电商平台一样层出不穷。今天就来跟大家分享最近发现比价好做的外贸电商平台APP——Carousell。号称海外版“咸鱼”&#xff0c;它的功能也与咸鱼是差不多的&#xf…

群晖ssh登录并开启root用户登录功能

说明 群辉默认不允许SSH使用ROOT远程登陆&#xff0c;只能用手动创建的账户登陆&#xff0c;需要拷贝破解文件的时候会提示权限不足&#xff0c;这个时候肯定需要通过root用户去登录靠北 启动ssh登录功能 双击控制面板 点击终端和SNMP 启用ssh和telnet 点击应用 finalshel…

SpringBoot入门:使用IDEA构建第一个SpringBoot项目

SpringBoot框架介绍 Spring Boot是一个简化Spring开发的框架&#xff0c;用来监护spring应用开发&#xff0c;约定大于配置&#xff0c;去繁就简&#xff0c;just run 就能创建一个独立的&#xff0c;产品级的应用。我们在使用Spring Boot时只需要配置相应的Spring Boot就可以…

编译原理三:词法分析

概念 在编译器工作流程中&#xff0c;词法分析是将源代码分解为一系列词法单元的过程。 词法单元包括标识符、关键字、运算符等。词法分析器会读取源代码的每一个字符&#xff0c;根据预定义的规则将它们组成一系列词法单元。 词法分析器通常使用有限状态机来实现。有限状态机…

如何解决在vue3+vite项目中加载不了.tga文件的问题

因项目需求所以需要加载 .tga 类型的文件 import backgroundImage from "/assets/combined_image.tga" import { TGALoader } from "three/addons/loaders/TGALoader.js";const loader new TGALoader(); const texture1 loader.load(backgroundImage);但…

操作系统5:线程的概念和线程实现

目录 1、线程的概念 &#xff08;1&#xff09;进程和进程并发是所需要付出的时空开销 &#xff08;2&#xff09;线程和进程的比较 &#xff08;3&#xff09;线程的状态和线程的控制块 2、线程的实现 &#xff08;1&#xff09;线程的实现方式 &#xff08;2&#xff…

2.编程语言的代码规则和规范

**格式和规范**只需要记住最原始的c和c的语言规则就可以了不要把所有的方法都掌握了 比如孔乙己 每个语法之间要有空格或分隔符 2。“”英文双引号里面是不需要的&#xff0c;这个双引号里面输入什么都可以 3.预处理的命令 必须一条占一行

传统美业如何拓客引流?如何借力小程序实现低成本引流与锁客

​传统门店的经营方式主要靠广告投入和口碑传播&#xff0c;然而&#xff0c;门店客流寥寥无几&#xff0c;如今&#xff0c;移动互联网时代&#xff0c;新零售的盛行&#xff0c;传统实体门店急需转型&#xff0c;接轨新的商业营销模式来为门店引流。 处在小程序爆发的风口&a…

《PyTorch深度学习实践》第四讲 反向传播

b站刘二大人《PyTorch深度学习实践》课程第四讲反向传播笔记与代码&#xff1a;https://www.bilibili.com/video/BV1Y7411d7Ys?p4&vd_sourceb17f113d28933824d753a0915d5e3a90 对于上述简单的模型可以用解析式来做&#xff0c;但是对于复杂模型而言&#xff0c;如下图每个…