Detailed explanation of Docker common commands Study03

Detailed explanation of Docker common commands Study03

1. Help Command

1. View the current Docker version

docker version

2. Display Docker system information, including images and container numbers

docker info

3. View the help document, similar to the Man command of CentOS

docker --help

2. Mirror command

1. View the image on the local host:

#List all local images (including intermediate image layers)
docker images -a 
#Only display the image ID
docker images -q 
#Show complete image information docker images --no-trunc

2. Search for images: https://hub.docker.com

docker search [OPTIONS] image nameOPTIONS: --no-trunc: Display the complete image description -s: List images with a collection count not less than the specified value --automated: Only list images of the automated build type;

2. Download the image

docker pull image name [:TAG]
TAG: The default version is latest.

3. Delete the image

#Delete a single docker rmi image name or ID
docker rmi -f image ID
#Batch delete docker rmi -f image name 1: TAG image name 2: TAG 
#Delete all images docker rmi -f $(docker images -qa)

3. Container Commands

1. Create and start a container

docker run [OPTIONS] IMAGE_NAME [COMMAND] [ARG...]

OPTIONS Description
–name="Container new name" : Specify a name for the container;
-d : Run the container in the background and return the container ID, which means starting a daemon container;
-i : Run the container in interactive mode, usually used with -t;
-t : reallocate a pseudo input terminal for the container, usually used with -i;
-P: Random port mapping;
-p: Specify port mapping ( hostPort:containerPort )

2. View all currently running containers

docker ps [OPTIONS]

OPTIONS Description
-a : List all currently running containers + containers that have been run in the past
-l : Display recently created containers
-n : Display the last n created containers
-q : Silent mode, only display container number
--no-trunc : Do not truncate output

3. Exit the container

exit The container stops and exits ctrl+P+Q The container does not stop and exits

4. Start the container

docker start container ID or container name

5. Restart the container

docker restart container ID or container name

6. Stop the container

docker stop container ID or container name

7. Force stop the container

docker kill container ID or container name

8. Delete the stopped container

docker rm container ID
#Delete multiple containers at once docker rm -f $(docker ps -a -q)

9. Enter the running container and interact with it from the command line

Start a new process in the container and open the terminal

docker exec -it container ID /bin/sh

Directly enter the terminal of the container startup command, and no new process will be started

docker attach container id

10. Copy files from the container to the host

docker cp container ID: path in container destination host path

11. Copy files from the host to the container

docker cp Host file or directory to be copied Container name: container file or directory

12. View the container mount directory

docker inspect container_name
docker inspect container_id

This directory is the location of your container data volume

insert image description here

13. Related image startup commands

RabbitMQ:

docker run -d --hostname localhost --name rabbitmq -p 15672:15672 -p 5672:5672 rabbitmq:management

This is the end of this article about Docker-Common Commands-Study03. For more information about Docker Common Commands Study03, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Summary of common docker commands (recommended)
  • Summary of Docker common commands and tips
  • Docker common command operation method
  • Summary of common Docker commands: installation, mirroring, and basic container operations
  • Detailed explanation of modifying docker time zone and common docker commands
  • Summary of common docker commands

<<:  Example of implementing the skeleton screen of WeChat applet

>>:  HTML table markup tutorial (39): The bright border color attribute of the header BORDERCOLORLIGHT

Recommend

Vue implements countdown between specified dates

This article example shares the specific code of ...

Using nginx + fastcgi to implement image recognition server

background A specific device is used to perform i...

Vue implements user login and token verification

In the case of complete separation of the front-e...

How to install MySQL for beginners (proven effective)

1. Software Download MySQL download and installat...

How to manage large file uploads and breakpoint resume based on js

Table of contents Preface Front-end structure Bac...

4 solutions to CSS browser compatibility issues

Front-end is a tough job, not only because techno...

Four ways to create objects in JS

Table of contents 1. Create objects by literal va...

Vue Page Stack Manager Details

Table of contents 2. Tried methods 2.1 keep-alive...

In-depth understanding of the use of CSS clear:both

clear:both is used to清除浮動This is the impression I...

How to solve the synchronization delay caused by MySQL DDL

Table of contents Preface Solution Tool Introduct...

Detailed explanation of character sets and validation rules in MySQL

1Several common character sets In MySQL, the most...

How to deploy the crownblog project to Alibaba Cloud using docker

Front-end project packaging Find .env.production ...

Sample code for configuring nginx to support https

1. Introduction Are you still leaving your websit...

Example code of how to create a collapsed header effect using only CSS

Collapsed headers are a great solution for displa...

Use pure JS to achieve the secondary menu effect

This article example shares the specific code of ...