Get the App
SLTechnology News&Howtos  ›  Servers  › 

The first acquaintance of container in docker Learning

Shulou Source: shulou.com Published: 2022-06-03 04:35:55 10月01日 Update

image is a class, container is an instantiated class object

The fastest way to create a container based on an image is

docker run skinglzw/hello-world Running a docker is a container

cd /root/hello-world

View containers currently running locally

docker container ls

docker container ls -a Lists all containers, including running ones

more Dockerfile

docker run centos:7

Method for interactively running containers

docker run -it centos

Exit docker

exit

docker image Enter

docker container Enter

delete a container

docker container rm 3b507da48bdc equals docker rm 3b507da48bdc

docker container ls -a equals docker ps -a

Delete image

docker image rm fce289e99eb9 equals docker rmi fce289e99eb9

docker run skinglzw/hello-world executes 5 times to create container

docker ps -a

docker container ls -aq enumerates all containerId similar to docker container ls -a| awk {'print$1'}

docker rm $(docker container ls -aq) Delete all containers

docker

There are 5 identical image containers deleted in batches

docker container ls -f "status=exited" List the status is exited

docker container ls -f "status=exited" -q List containerId only

docker rm $(docker container ls -f "status=exited" -q)

Tags: Container run method being fastest interactive instance object that is state learn it Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno vpn MySQL Docker Shulou Technology Shulou Tech Info