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

这篇具有很好参考价值的文章主要介绍了尚硅谷Docker实战教程-笔记03【Docker常用命令】。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

  • 尚硅谷大数据技术-教程-学习路线-笔记汇总表【课程资料下载】
  • 视频地址:尚硅谷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

尚硅谷Docker实战教程-笔记03【Docker常用命令】,# Docker,docker,linux,容器,常用命令,镜像

[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

尚硅谷Docker实战教程-笔记03【Docker常用命令】,# Docker,docker,linux,容器,常用命令,镜像

[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

尚硅谷Docker实战教程-笔记03【Docker常用命令】,# Docker,docker,linux,容器,常用命令,镜像

[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

尚硅谷Docker实战教程-笔记03【Docker常用命令】,# Docker,docker,linux,容器,常用命令,镜像

尚硅谷Docker实战教程-笔记03【Docker常用命令】,# Docker,docker,linux,容器,常用命令,镜像

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

尚硅谷Docker实战教程-笔记03【Docker常用命令】,# Docker,docker,linux,容器,常用命令,镜像

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

尚硅谷Docker实战教程-笔记03【Docker常用命令】,# Docker,docker,linux,容器,常用命令,镜像

尚硅谷Docker实战教程-笔记03【Docker常用命令】,# Docker,docker,linux,容器,常用命令,镜像

[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

尚硅谷Docker实战教程-笔记03【Docker常用命令】,# Docker,docker,linux,容器,常用命令,镜像

[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# 

尚硅谷Docker实战教程-笔记03【Docker常用命令】,# Docker,docker,linux,容器,常用命令,镜像文章来源地址https://www.toymoban.com/news/detail-516705.html

  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   # 截取容器停止时的退出状态值

到了这里,关于尚硅谷Docker实战教程-笔记03【Docker常用命令】的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包赞助服务器费用

相关文章

  • 尚硅谷Docker实战教程-笔记13【高级篇,Docker轻量级可视化工具Portainer】

    尚硅谷Docker实战教程-笔记13【高级篇,Docker轻量级可视化工具Portainer】

    尚硅谷大数据技术-教程-学习路线-笔记汇总表【课程资料下载】 视频地址:尚硅谷Docker实战教程(docker教程天花板)_哔哩哔哩_bilibili 尚硅谷Docker实战教程-笔记01【基础篇,Docker理念简介、官网介绍、平台入门图解、平台架构图解】 尚硅谷Docker实战教程-笔记02【基础篇,Do

    2024年02月15日
    浏览(50)
  • 尚硅谷Docker实战教程-笔记05【本地镜像发布到阿里云与私有库】

    尚硅谷Docker实战教程-笔记05【本地镜像发布到阿里云与私有库】

    尚硅谷大数据技术-教程-学习路线-笔记汇总表【课程资料下载】 视频地址:尚硅谷Docker实战教程(docker教程天花板)_哔哩哔哩_bilibili 尚硅谷Docker实战教程-笔记01【理念简介、官网介绍、平台入门图解、平台架构图解】 尚硅谷Docker实战教程-笔记02【安装docker、镜像加速器配置

    2024年02月12日
    浏览(23)
  • 尚硅谷大数据Flink1.17实战教程-笔记03【Flink运行时架构】

    尚硅谷大数据Flink1.17实战教程-笔记03【Flink运行时架构】

    尚硅谷大数据技术-教程-学习路线-笔记汇总表【课程资料下载】 视频地址:尚硅谷大数据Flink1.17实战教程从入门到精通_哔哩哔哩_bilibili 尚硅谷大数据Flink1.17实战教程-笔记01【Flink概述、Flink快速上手】 尚硅谷大数据Flink1.17实战教程-笔记02【Flink部署】 尚硅谷大数据Flink1.17实

    2024年02月16日
    浏览(20)
  • Docker实战:Docker常用命令

    参考:https://blog.csdn.net/weixin_45509582/article/details/125599521 输出依次为,进程pid、容器ID、容器名、存储work路径,即可确定是哪个容器。 参考:https://blog.csdn.net/sebeefe/article/details/123732823

    2024年02月12日
    浏览(11)
  • Docker笔记 Docker架构与常用命令

    Docker笔记 Docker架构与常用命令

    大家好 我是积极向上的湘锅锅💪💪💪 首先Docker由三大部分组成 Clients:客户端 通过docker的客户端操作命令,然后命令发送到daemon(守护进程)里面去执行操作 Hosts:主机 主机包括俩个部分,分别是 local host 和 remote host ,意思是本机和远程的机器。 而在local host这个部分里面

    2024年02月13日
    浏览(7)
  • 【云原生】1.3 Docker 常用命令实战(上)

    【云原生】1.3 Docker 常用命令实战(上)

    哈喽~大家好呀,上两篇呢我们讲了云原生的概念以及Docker基本概念,通过这两篇的学习之后我们对云原生有了一定的了解,这篇呢我们来看看“ Docker命令实战 ” 吧。  🥇个人主页:个人主页​​​​​             🥈 系列专栏:【云原生系列】 🥉与这篇相关的文章:

    2023年04月08日
    浏览(5)
  • Docker实战技巧(一):常用命令与最佳实践

    一、原理 1、Hypervisor是一种运行在物理服务器和操作系统之间的中间软件层,可允许多个操作系统和应用共享一套基础物理硬件,它能直接访问物理设备,会给每一台虚拟机分配内存、CPU、网络、磁盘等资源,也可以确保虚拟机对应的硬件资源不被其他虚拟机访问,是所有虚

    2024年02月09日
    浏览(8)
  • Docker搭建LNMP环境实战(06):Docker及Docker-compose常用命令

    Docker搭建LNMP环境实战(06):Docker及Docker-compose常用命令

    此处列举了docker及docker-compose的常用命令,一方面可以做个了解,另一方面可以在需要的时候进行查阅。不一定要强行记忆,用多了就熟悉了。 1.1、镜像常用命令 1)列举镜像 2)删除镜像 3)使用repositories:tag进行删除 1.2、容器常用命令 1)列举所有容器 2)列举正在运行的容

    2024年03月27日
    浏览(11)
  • 尚硅谷大数据技术Hadoop教程-笔记03【Hadoop-HDFS】

    尚硅谷大数据技术Hadoop教程-笔记03【Hadoop-HDFS】

    视频地址: 尚硅谷大数据Hadoop教程(Hadoop 3.x安装搭建到集群调优) 尚硅谷大数据技术Hadoop教程-笔记01【大数据概论】 尚硅谷大数据技术Hadoop教程-笔记02【Hadoop-入门】 尚硅谷大数据技术Hadoop教程-笔记03【Hadoop-HDFS】 尚硅谷大数据技术Hadoop教程-笔记04【Hadoop-MapReduce】 尚硅谷

    2023年04月08日
    浏览(12)
  • Docker容器常用命令笔记分享

    Docker容器常用命令笔记分享

    Docker是一个开源的应用容器引擎,可以让开发者将应用程序及其依赖打包成一个可移植的容器,然后发布到任何支持Docker的机器上,实现应用程序在不同环境中的一致性运行。相比传统的虚拟化技术,Docker具有更轻量级、更快速、更高效的特点。使用Docker可以方便地创建、部

    2024年03月17日
    浏览(11)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包