Some commands commonly used in docker

1. Help command
docker version
docker info
docker --help
2. Mirror command
① List the mirrors of the local host: docker images
Insert picture description here

Description of each option:
REPOSITORY: indicates the warehouse source of the
mirror TAG: the tag of the mirror
IMAGE ID: the mirror ID
CREATED: the creation time of the
mirror SIZE: the mirror size The
same warehouse source can have multiple TAGs, representing different versions of the warehouse source, we use REPOSITORY:TAG to define different images.
If you do not specify a mirror version tag, for example, if you only use centos, docker will use centos:latest mirror
options by default. Description:
Insert picture description here

②docker search

③docker pull
Insert picture description here

④docker rmi
Insert picture description here

3. Container commands.
Prerequisite:
Only a mirror can be used to create a container. Download a mirror: docker pull centos
① Create a new container and start
docker run [options] Mirror name /bin/bash
OPTIONS description (commonly used): some are a minus sign, some are two Minus sign
–name="container new name": specify a name for the container;
-d: run the container in the background and return the container ID, that is, start the daemon container;
-i: run the container in interactive mode, usually at the same time as -t Use;
-t: reassign a pseudo input terminal for the container, usually used at the same time as -i;
-P: random port mapping;
-p: specify port mapping, there are the following four formats
ip:hostPort:containerPort
ip::containerPort
hostPort :containerPort
containerPort
Real column:
Insert picture description here

#Use the mirror centos:latest to start a container in interactive mode, and execute the /bin/bash command in the container.
docker run -it centos /bin/bash ②Exit the
container
(1) exit: the container stops and exits
(2) ctrl+P+Q: the container does not stop and exit
Insert picture description here


③View container logs docker logs -f -t --tail container id

  • -t is to add timestamp
  • -f follow the latest log print
  • --Tail number shows the last number
    Insert picture description here


④View the process running in the container docker top container id ⑤View the
internal details of the container
docker inspect container id ⑥Enter the
running container and interact with the command line
(1) docker exec -it container id bashshell
directly enter the terminal of the container startup command, Will not start a new process
(2) docker attach container id
is to open a new terminal in the container, and can start a new process
⑦ copy files from the container to the host
docker cp container id: the destination host path in the container

Insert picture description here

Guess you like

Origin blog.csdn.net/weixin_44703894/article/details/113370094