In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces what Docker 03 commonly used mirror images and container commands have, the content is very detailed, interested friends can refer to, hope to be helpful to you.
Command one is divided into two large blocks: mirror command and container command
1. Mirror related commands
View image docker images
REPOSITORY: image name
TAG: mirroring
IMAGE ID: mirror ID
CREATED: the date the image was created (not the date on which the image was obtained)
SIZE: mirror siz
These images are stored in the / var/lib/docker directory of the Docker host
Search for image docker search image name (if you need to find the image you need from the network, you can search with the following command)
NAME: warehouse name
DESCRIPTION: image description
STARS: user evaluation, reflecting the popularity of an image
OFFICIAL: is it official?
AUTOMATED: built automatically, indicating that the image was created by the Docker Hub automatic build process
Note: do not randomly under the image, I suggest the official image, because I do not know whether there is poison in the image uploaded by others!
Pull image docker pull image name (pull image is to download image to local from central repository)
For example, I want to download the centos7 image
Docker pull centos:7
Delete a mirror (delete a mirror by mirror ID) docker rmi Mirror ID
Delete all images docker rmi `docker images-q`
two。 Container related commands
View the container
View the container docker ps that is running
View all containers docker ps-a
View the container docker ps-l that was last run
View the stopped container docker ps-f status=exited
Create and start the container
Description of parameters commonly used in creating containers
Create Container Command: docker run
-I: means to run the container
-t: indicates that the container will enter its command line after startup. After adding these two parameters, the container creation can be logged in. That is, assign a pseudo terminal.
-- name: name the created container.
-v: indicates the directory mapping relationship (the former is the host directory and the latter is the directory mapped to the host). You can use multiple-v to map multiple directories or files. Note: it is best to do directory mapping, make changes on the host, and then share them on the container.
-d: add the-d parameter after run, and a guardian container will be created to run in the background (in this way, the container will not be automatically logged in after it is created. If only-I-t is added, the container will be automatically entered after creation).
-p: indicates the port mapping. The former is the host port, and the latter is the mapped port in the container. You can use multiple-p for multiple port mappings.
(1) create containers interactively
Docker run-it-- name= container name image name: label / bin/bash
At this time, we check through the ps command and find that we can see the startup container and the status is in the startup state.
Exit the current container
Exit
(2) create containers in a guarded manner:
Docker run-di-- name= container name image name: label
Log in to the guarded container:
Docker exec-it container name (or container ID) / bin/bash
Stop and start the container
Stop the container:
Docker stop container name (or container ID)
Start the container:
Docker start container name (or container ID)
File copy
If we need to copy the file into the container, we can use the cp command
File or directory to be copied by docker cp Container name: container directory
You can also copy files from the container
Docker cp container name: the file or directory that needs to be copied in the container directory
Directory mount
When creating a container, we can map the directory of the host to the directory in the container, so that we can affect the container by modifying the files in a directory of the host.
Create a container and add the-v parameter followed by the host directory: container directory, for example:
Docker run-di-v / usr/local/myhtml:/usr/local/myhtml-- name=mycentos3 centos:7
If you are sharing a multi-level directory, you may be prompted for insufficient permissions.
This is because the security module selinux in CentOS7 forbids permissions. We need to add the parameter privileged=true to solve the problem that mounted directories do not have permissions.
Check the container IP address
We can view the various data that the container is running with the following command
Docker inspect container name (container ID)
You can also directly execute the following command to directly output the IP address
Ocker inspect-format=' {{.NetworkSettings.IPAddress}} 'Container name (Container ID)
Delete Container
Delete the specified container: docker rm container name (container ID)
This is the end of sharing the commands of Docker 03 commonly used images and containers. I hope the above can help you and learn more. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.