I'm operating simple kubernetes cluster(CRI is containerd).
In the cluster, "crictl ps" command doesn't return "kubelet" container.
In another kubernetes cluster(CRI is docker), "docker ps" command returns "kubelet" container.
What is the difference between these two commands(docker ps / crictl ps)?
Is there any way to see "kubelet" container by "crictl ps" command?
crictl isn't a replacement for docker. The result of crictl ps doesn't include some containers (e.g. pause).
Try ctr -n k8s.io c ls to see all the containers running on k8s with containerd.
Related
What is the equivalent of docker inspect in containerd.
You can inspect the container in containerd by using info in containerd.
First list out the containers that you are looking to inspect
ctr --namespace k8s.io containers ls
Containerd has namespaces https://github.com/containerd/containerd/blob/master/README.md#namespaces , so use --namespaces flag or ns flag, Above k8s.io is namespace
After getting the list of containers , you can get info about a particular container that you want using below command
syntax:
ctr --namespace <namespace_name> containers info <container_id>
ex :
ctr --namespace k8s.io containers info 85ed1aeb518ff57f6cc5b80c599f0c4bfcc8e944f842c98aeed5ffceaa5e6aaa
I am running a docker image using the following command:
sudo docker run -it -v "${pwd}:/qc/output" qc
It works perfectly then I used the following command to get the list of existing docker containers
sudo docker ps --filter ancestor=ubuntu
but it returns only headers which is the following line:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
do you know why it is empty and how I can get the information for the existing docker containers?
you will get all running containers details by command
docker ps
use docker ps -a to see all active and non-active container details
I pull the tensorflow/serving in docker-for-windows Linux containers
PS C:\WINDOWS\system32> docker pull tensorflow/serving
Using default tag: latest
latest: Pulling from tensorflow/serving
Digest: sha256:f7e59a29cbc17a6b507751cddde37bccad4407c05ebf2c13b8e6ccb7d2e9affb
Status: Image is up to date for tensorflow/serving:latest
docker.io/tensorflow/serving:latest
After that for any following commands the container is not listing up
PS C:\WINDOWS\system32> docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
PS C:\WINDOWS\system32> docker container ls -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
PS C:\WINDOWS\system32> docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
I tried restarting docker as well, may I know how to fix it?
docker pull is pulling the image you selected
You don't have a container yet.
docker ps and the other commands you used are referring to containers.
So to run the container use:
docker run {options} image
After that you be able to see the container using docker ps
When you run docker pull tensorflow/serving the Docker image will get pulled, which can be listed using docker images command.
While docker ps, docker container ls -a, docker container ls will list running docker container. You need to run your Docker image using docker run image-name then the container will get listed using the mentioned commands.
For more info on Docker, please refer this official guide.
When I launch docker, it launch by default a few containers that I have build in the past.(I've use docker-compose at the time, but deleted the repo since)
I kill them, but each time i restart docker, they are back.
What can I do ?
I know there is something like "docker system prune",
but I would like to delete the less possible .
You can try running docker ps -a to get a list of all containers including the ones which are not running but stopped.
You can then docker rm each container you do not wish to start on each docker restart.
Use docker ps to see what containers are running.
Use this command to kill/stop all running containers.
docker rm $(docker ps -a -q)
Use docker images to get list of all images.
Use docker rmi <image_id> to delete desired image.
docker ps is giving me a different output compared to docker-compose ps.
For example
docker ps
is not showing the same containers as
docker-compose ps
and vice-versa.
What is the reason for this?
I was thinking docker-compose is working on top of docker.
docker ps lists all running containers in docker engine. docker-compose ps lists containers related to images declared in docker-compose file.
The result of docker-compose ps is a subset of the result of docker ps.
docker ps - lists all running containers in Docker engine.
docker-compose ps - lists containers for the given docker compose configuration. The result will depend on configuration and parameters passed to docker-compose command.
Example
Start the containers with the following command:
docker-compose -p prod up -d
(-p in the command above defines the project name)
Running docker-compose ps won't list containers since the project name parameters is not passed:
docker-compose ps
Name Command State Ports
------------------------------
Running docker-compose -p prod ps will list all containers:
Name Command State Ports
--------------------------------------------------------------------------------------------------------
dev_app_1 sh -c exec java ${JAVA_OPT ... Up 0.0.0.0:5005->5005/tcp, 0.0.0.0:9001->9000/tcp
dev_database_1 docker-entrypoint.sh postgres Up 0.0.0.0:5432->5432/tcp
dev_nginx_1 /docker-entrypoint.sh ngin ... Up 0.0.0.0:8443->443/tcp, 0.0.0.0:8080->80/tcp
dev_pgadmin_1 /entrypoint.sh Up 443/tcp, 0.0.0.0:9100->80/tcp
The same goes if you define for example docker compose files with -f parameter.