In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces how to use docker in Linux. The content is very detailed. Interested friends can use it for reference. I hope it will be helpful to you.
# list all currently running containers $docker ps# list all containers $docker ps-a # list recently launched containers $docker ps-l # View container information $docker inspect $CONTAINER_ID
Delete a container:
Docker rm Container id
=
When using docker run to create containers, standard operations for Docker to run in the background include:
Check whether the specified image exists locally. Download it from the public repository if it does not exist.
Create and start a container using an image
Assign a file system and mount a read-write layer outside the read-only mirror layer
Bridge a virtual interface to the container from the bridge interface configured by the host host
Configure an ip address from the address pool to the container
Execute a user-specified application
The container is terminated after execution
=
View mirrors that exist in the system
[root@izuf63bjp8ts8nkl13pxh2z ~] # docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEdocker.io/centos latest 67591570dd29 12 weeks ago 191.8 MB
=
Create a new container:
Docker run-I-t centos / bin/bash
View the container id that is running:
[root@izuf63bjp8ts8nkl13pxh2z /] # docker psCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES71d5ec72a193 centos "/ bin/bash" 56 minutes ago Up 56 minutes prickly_albattani0f72d2a74111 centos "/ bin/bash" About an hour ago Up About an hour condescending_poitras
Modify the file in the container 71d5ec72a193.
If you want to quit but do not destroy it, you can CTRL+p+q. This is whether the container 71d5ec72a193 is running in the background.
Then reconnect can use the command:
Docker attach 71d5ec72a193
Or use the following command:
Docker exec-it CONTAINER_ID / bin/bash enters the specified container
If you use exec, it will not be destroyed after exiting with exit.
Even if the container is destroyed, it can be re-entered:
Docker start 71d5ec72a193 docker attach 71d5ec72a193
=
There are two ways to build an image:
Method one. Use the docker commit command
Method two. Use docker build commands and Dockerfile files
Method 1:
[root@izuf63bjp8ts8nkl13pxh2z ~] # docker images-- View the current images in the system REPOSITORY TAG IMAGE ID CREATED SIZEdocker.io/centos latest 67591570dd29 12 weeks ago 191.8 MB [root@izuf63bjp8ts8nkl13pxh2z ~] # docker commit 71d5ec72a193 docker.io/centos-fx01-- create an image based on the container id=71d5ec72a193, the creation library is docker.io, and the name of the newly generated image is centos-fx01sha256:6f86477df3c7a929b2ca8d9eee32cf278302f5eccd51338927d351ab0f9066b4 [root@izuf63bjp8ts8nkl13pxh2z ~] # docker images-- View the images available in the system. Generate a new image centos-fx01 successfully REPOSITORY TAG IMAGE ID CREATED SIZEdocker.io/centos-fx01 latest 6f86477df3c7 29 seconds ago 191.8 MBdocker.io/centos latest 67591570dd29 12 weeks ago 191.8 MB [root@izuf63bjp8ts8nkl13pxh2z ~] # docker run-it centos-fx01 / bin/bash-- create a container root@806b7e2c0201 /] # ls with this new image-- create a new container id=806b7e2c0201 [root@izuf63bjp8ts8nkl13pxh2z ~] # docker ps-a-- View all containers You can see that the image for container id=806b7e2c0201 is centos-fx01 CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES806b7e2c0201 centos-fx01 "/ bin/bash" 57 seconds ago Exited (0) 6 seconds ago kickass_kare71d5ec72a193 centos "/ bin/bash" 3 hours ago Exited (0) 8 minutes ago prickly_albattani0f72d2a74111 centos "/ bin/bash" 3 hours ago Exited (0) About an hour ago condescending_poitras
=
Create a new container and mount the host directory to the container directory:
Docker run-I-t-v / data/software/:/data/software/ centos-fx01 / bin/bash
Rename the container:
Docker rename oldC newC
Delete the image (container needs to be stopped):
Docker stop $(docker ps-a-Q) docker rmi on how to use docker in Linux to share here, I hope the above content can be of some help to you, can learn more knowledge. 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.