Docker info shows containers but docker container ls doesn't - docker

When I run docker info, it shows that I have 18 containers running.
% docker info
Client:
Debug Mode: false
Server:
Containers: 18
Running: 18
Paused: 0
Stopped: 0
Images: 9
...
I want to delete these containers, but when I run docker container ls -a, it shows an empty list. How can I find them?
These containers are not allowing me to delete images.
% docker rmi -f 1e94481e8f30
Error response from daemon: conflict: unable to delete 1e94481e8f30 (cannot be forced) - image is being used by running container 7e9b08a0007b

You are probably running kubernetes.
After stopping kubernetes, to remove all stopped containers and all images without at least one container associated to them:
docker system prune --all

To stop all running containers
docker stop $(docker ps -a -q)
To remove all containers
docker rm $(docker ps -a -q)
You should be able to delete all images after that

Those 18 containers belong to Kubernetes. You can check this by going to the Preferences > Kubernetes > Check Show system containers (advanced).
After that, just run docker container ls -a again and you will see those 18 containers.
These are the containers you are not seeing unless you check that option:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6c3c65d4bcf4 a8c3d87a58e7 "/compose-controller…" 3 minutes ago Up 3 minutes k8s_compose_compose-6c67d745f6-sr4zj_docker_34e7ef25-166e-11ea-857d-025000000001_2
663d6419ce76 eb516548c180 "/coredns -conf /etc…" 3 minutes ago Up 3 minutes k8s_coredns_coredns-6dcc67dcbc-2twts_kube-system_0c8d1f5f-166e-11ea-857d-025000000001_2
d04a4caf922d eb516548c180 "/coredns -conf /etc…" 3 minutes ago Up 3 minutes k8s_coredns_coredns-6dcc67dcbc-chk2l_kube-system_0c8df4b4-166e-11ea-857d-025000000001_2
324d5d216b07 f3591b2cb223 "/api-server --kubec…" 3 minutes ago Up 3 minutes k8s_compose_compose-api-57ff65b8c7-svv9t_docker_34e161f1-166e-11ea-857d-025000000001_2
f9f74acd5ab6 849af609e0c6 "/usr/local/bin/kube…" 3 minutes ago Up 3 minutes k8s_kube-proxy_kube-proxy-w4x7l_kube-system_0c95526c-166e-11ea-857d-025000000001_2
3cbfa75f1466 k8s.gcr.io/pause:3.1 "/pause" 3 minutes ago Up 3 minutes k8s_POD_compose-6c67d745f6-sr4zj_docker_34e7ef25-166e-11ea-857d-025000000001_2
f11f1cc4bbba k8s.gcr.io/pause:3.1 "/pause" 3 minutes ago Up 3 minutes k8s_POD_coredns-6dcc67dcbc-chk2l_kube-system_0c8df4b4-166e-11ea-857d-025000000001_2
cbb52fdaf130 k8s.gcr.io/pause:3.1 "/pause" 3 minutes ago Up 3 minutes k8s_POD_coredns-6dcc67dcbc-2twts_kube-system_0c8d1f5f-166e-11ea-857d-025000000001_2
5ad88766f27d k8s.gcr.io/pause:3.1 "/pause" 3 minutes ago Up 3 minutes k8s_POD_compose-api-57ff65b8c7-svv9t_docker_34e161f1-166e-11ea-857d-025000000001_2
9f326ea7db5d k8s.gcr.io/pause:3.1 "/pause" 3 minutes ago Up 3 minutes k8s_POD_kube-proxy-w4x7l_kube-system_0c95526c-166e-11ea-857d-025000000001_2
ea36a7a0d248 f1e3e5f9f93e "kube-scheduler --bi…" 3 minutes ago Up 3 minutes k8s_kube-scheduler_kube-scheduler-docker-desktop_kube-system_ef4d089e81b94aa15841e51ed8c41712_2
f3dfa711ea0f 1e94481e8f30 "kube-apiserver --ad…" 3 minutes ago Up 3 minutes k8s_kube-apiserver_kube-apiserver-docker-desktop_kube-system_b1dff398070b11d23d8d2653b78d430e_2
1e5cf76eaf20 2c4adeb21b4f "etcd --advertise-cl…" 3 minutes ago Up 3 minutes k8s_etcd_etcd-docker-desktop_kube-system_3773efb8e009876ddfa2c10173dba95e_2
d631fca0d4ac k8s.gcr.io/pause:3.1 "/pause" 3 minutes ago Up 3 minutes k8s_POD_kube-scheduler-docker-desktop_kube-system_ef4d089e81b94aa15841e51ed8c41712_2
20242b387b05 36a8001a79fd "kube-controller-man…" 3 minutes ago Up 3 minutes k8s_kube-controller-manager_kube-controller-manager-docker-desktop_kube-system_86e291a2049db314a5eca69a05cf6ced_2
b32c2d63090f k8s.gcr.io/pause:3.1 "/pause" 3 minutes ago Up 3 minutes k8s_POD_kube-apiserver-docker-desktop_kube-system_b1dff398070b11d23d8d2653b78d430e_2
4d6e49f60ead k8s.gcr.io/pause:3.1 "/pause" 3 minutes ago Up 3 minutes k8s_POD_etcd-docker-desktop_kube-system_3773efb8e009876ddfa2c10173dba95e_2
9035ccdcae5d k8s.gcr.io/pause:3.1 "/pause" 3 minutes ago Up 3 minutes k8s_POD_kube-controller-manager-docker-desktop_kube-system_86e291a2049db314a5eca69a05cf6ced_2

Related

Copy a file from local machine to docker container

I am following this example:
I find the namenode as follows:
(dash_apps_36) idf#ubvm:~/Documents/docker-hadoop$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2ce71013488f bde2020/hadoop-resourcemanager:2.0.0-hadoop3.2.1-java8 "/entrypoint.sh /run\u2026" 17 minutes ago Up 17 minutes (healthy) 8088/tcp resourcemanager
7fc72b887e23 bde2020/hadoop-namenode:2.0.0-hadoop3.2.1-java8 "/entrypoint.sh /run\u2026" 17 minutes ago Up 17 minutes (healthy) 0.0.0.0:9000->9000/tcp, 0.0.0.0:9870->9870/tcp namenode
9c3f8c435b87 bde2020/hadoop-nodemanager:2.0.0-hadoop3.2.1-java8 "/entrypoint.sh /run\u2026" 17 minutes ago Up 17 minutes (healthy) 8042/tcp nodemanager
4d57c5bf2f9e bde2020/hadoop-datanode:2.0.0-hadoop3.2.1-java8 "/entrypoint.sh /run\u2026" 17 minutes ago Up 17 minutes (healthy) 9864/tcp datanode
c7eef33905e8 bde2020/hadoop-historyserver:2.0.0-hadoop3.2.1-java8 "/entrypoint.sh /run\u2026" 17 minutes ago Up 17 minutes (healthy) 8188/tcp historyserver
2b1144867924 redis "docker-entrypoint.s\u2026" 6 days ago Exited (137) 6 days ago serene_keldysh
9d9463166b63 redis "docker-entrypoint.s\u2026" 6 days ago Created eloquent_merkle
47d6488e29bf redis:alpine "docker-entrypoint.s\u2026" 4 weeks ago Exited (137) 4 weeks ago wikipedia-playground_redis_1
be5ea0df0401 mcr.microsoft.com/mssql/server:2019-latest "/opt/mssql/bin/perm\u2026" 18 months ago Exited (255) 18 months ago 0.0.0.0:1433->1433/tcp mssql
Using 7fc72b887e23 as the ID of the namenode, when I get to the command
$ docker cp ../hadoop-mapreduce-examples-2.7.1-sources.jar cb0c13085cd3:hadoop-mapreduce-examples-2.7.1-sources.jar
I get an error:
$: command not found
Not sure what I am doing wrong.
Remove the $ at the beginning. That's what $: command not found means. Easy to miss when copy pasting code
docker cp ../hadoop-mapreduce-examples-2.7.1-sources.jar cb0c13085cd3:hadoop-mapreduce-examples-2.7.1-sources.jar

how to use the same container which was exited in docker

I had created a lot of containers. I am new to this docker container system.
I do a docker ps -a then I get following result
debian#osboxes:~$ docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a6a62181dcf0 python "/bin/bash" About a minute ago Exited (127) 8 seconds ago try1
ed5ef0b8155d 1d1a162a72a6 "/bin/bash" 22 hours ago Exited (0) 22 hours ago pedantic_ellis
19a4eff3b5e5 1d1a162a72a6 "/bin/bash" 22 hours ago Exited (0) 22 hours ago assignment4
30933891f08c eeadc22d21a9 "python3" 22 hours ago Exited (0) 22 hours ago python
ccdab94fd32f 1d1a162a72a6 "/bin/bash" 28 hours ago Exited (0) 24 hours ago confident_wu
ce462ecfc5f2 1d1a162a72a6 "/bin/bash -v /home/…" 28 hours ago Exited (127) 28 hours ago stupefied_grothendieck
6123f134934c 1d1a162a72a6 "/bin/bash" 28 hours ago Exited (1) 28 hours ago stupefied_taussig
0ed23a8112a4 1d1a162a72a6 "/bin/bash" 29 hours ago Exited (0) 29 hours ago vigilant_bartik
c343731b7cde 1d1a162a72a6 "/bin/bash" 30 hours ago Exited (0) 29 hours ago gallant_ardinghelli
2f95d3b4c1b8 1d1a162a72a6 "/bin/bash" 30 hours ago Created nice_hermann
5ebe9f18c744 1d1a162a72a6 "/bin/bash" 46 hours ago Created pensive_easley
c1b43edfafb9 1d1a162a72a6 "/bin/bash" 46 hours ago Exited (1) 22 hours ago adoring_williams
42dea69d1d4e 1d1a162a72a6 "/bin/bash" 46 hours ago Created funny_austin
6f736902e650 1d1a162a72a6 "/bin/bash" 46 hours ago Exited (1) 46 hours ago strange_ride
09306e5ec5d1 1d1a162a72a6 "--name=kaushik" 2 days ago Created pensive_shtern
699fb2a23e1c 1d1a162a72a6 "--name=kaushik" 2 days ago Created sharp_feistel
9f7b29ab512e 1d1a162a72a6 "--name=kaushik" 2 days ago Created elastic_payne2
25bfc74fab3b 1d1a162a72a6 "/bin/bash" 2 days ago Exited (1) 2 days ago festive_einstein
e658dd320297 1d1a162a72a6 "/bin/bash" 2 days ago Exited (255) 2 minutes ago objective_napier
ebae378d9152 1d1a162a72a6 "/bin/bash" 2 days ago Exited (1) 2 days ago brave_ritchie
23c7f4293b30 hadoop-build-1001 "/bin/bash" 2 days ago Exited (0) 2 days ago suspicious_lumiere
5090081f6809 hadoop-build-1001 "/bin/bash" 2 days ago Exited (1) 2 days ago quizzical_keller
425d59be9cbf hadoop-build-1001 "/bin/bash" 2 days ago Exited (0) 2 days ago distracted_lederberg
11c55ce7f011 hadoop-build-1001 "/bin/bash" 2 days ago Created elastic_noyce
1ccaf0477995 hadoop-build-1001 "/bin/bash" 2 days ago Created mystifying_tu
62528115f4b7 hadoop-build-1001 "/bin/bash" 2 days ago Created determined_meninsky
fca64af2f595 hadoop-build-1001 "/bin/bash" 2 days ago Created elastic_goldwasser
eecb3153bded hadoop-build-1001 "/bin/bash" 2 days ago Created cool_cray
30b6d61fcac9 hadoop-build-1001 "/bin/bash" 2 days ago Exited (1) 2 days ago quirky_kapitsa
cf992a8b8286 hadoop-build-1001 "/bin/bash" 2 days ago Created hungry_goldstine
0f9a951f7593 hadoop-build-1001 "/bin/bash" 2 days ago Created crazy_wright
e25dcf8a8be8 hadoop-build-1001 "/bin/bash" 2 days ago Created bold_pasteur
73d068e0d756 hadoop-build-1001 "/bin/bash" 2 days ago Exited (0) 2 days ago condescending_goodall
adda325294cd hadoop-build-1001 "/bin/bash" 2 days ago Exited (0) 2 days ago serene_wilson
75a9a3262505 hadoop-build-1001 "/bin/bash" 2 days ago Exited (0) 2 days ago hardcore_khorana
e38726a74e9b hadoop-build-1001 "/bin/bash" 3 days ago Exited (255) 2 days ago beautiful_clarke
4060dbc85d2d hadoop-build-1001 "/bin/bash" 3 days ago Exited (0) 3 days ago strange_yonath
174509213b30 hadoop-build-1001 "/bin/bash" 8 days ago Exited (255) 7 days ago hadoop-c
fa82c595e214 1d1a162a72a6 "/bin/bash" 8 days ago Exited (0) 8 days ago agitated_edison
4b07fcc45271 python "python3" 2 weeks ago Exited (255) 8 days ago pyC
1cc06f213eb7 abee520343a4 "/bin/sh -c 'apt-get…" 3 months ago Exited (100) 3 months ago compassionate_kowalevski
8c1eb67f7325 1b1c7b120b48 "/bin/sh -c 'cd /opt…" 3 months ago Exited (255) 3 months ago dreamy_jepsen
1406d7476a28 1180f37ef8b1 "/bin/sh -c 'mkdir -…" 3 months ago Exited (35) 3 months ago upbeat_taussig
e88bcf7743e2 f0f5acc11f91 "/bin/sh -c 'apt-get…" 3 months ago Exited (100) 3 months ago tender_cohen
I had made some changes in a container which was created using one of hadoop image as below
debian#osboxes:~$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
python latest eeadc22d21a9 2 weeks ago 933MB
hadoop-build-1001 latest 1d1a162a72a6 3 months ago 2.02GB
hadoop-build latest 5c1480006f78 3 months ago 1.96GB
ubuntu xenial 5f2bf26e3524 3 months ago 123MB
I powered off the machine and rebooted etc.
I want to know that I made changes to one of the containers say in above output of docker ps -a the container was
25bfc74fab3b 1d1a162a72a6 "/bin/bash" 2 days ago Exited (1)
how can after a reboot etc I connect or start the same container again.
What I am currently doing is
docker run -it 1d1a162a72a6 /bin/bash
I make some changes and run a few python programms. But after a reboot all the changes are gone that means those python files which I had edited I have to copy paste them again in the container and do every thing from scratch.I have to install vim each time and then each time I do apt-get update install softwares and then check edit the programe.
I am not able to understand how to go back to same container which was created moments ago before exiting. What mistake I am doing here?
docker run always starts a new container. You can re-attach to the existing container provided it wasn't started with --rm using docker start:
docker start -ai <CONTAINER_ID>
Notice that you should use container ID, not image ID as a parameter to docker start. See more in Docker help:
$ docker start --help
Usage: docker start [OPTIONS] CONTAINER [CONTAINER...]
Start one or more stopped containers
Options:
-a, --attach Attach STDOUT/STDERR and forward signals
--detach-keys string Override the key sequence for detaching a container
-i, --interactive Attach container's STDIN
I had made some changes in a container... after a reboot all the changes are gone that means those python files which I had edited I have to copy paste them again in the container and do every thing from scratch.I have to install vim each time and then each time I do apt-get update install softwares and then check edit the programe.
Containers are, by definition, immutable. What you were editing was a temporary runtime layer. If the container stopped or exited, you lose those changes.
In order to preserve changes, you must edit the Dockerfile and rebuild the container in order to create those immutable layers that the image contains
Realistically, you'd use a volume mount from the host into the container and edit code locally, which syncs into the container. No need for text editors or repeated apt updates

How can I stop the kafka container?

I setup my kafka containers by follow the tutorial from here: https://success.docker.com/article/getting-started-with-kafka
Then I found that I can't remove the container anymore, even though I tried docker container prune. The containers are still running.
What should I do?
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
caa0b94c1d98 qnib/plain-kafka:1.1.0 "/usr/local/bin/entr…" 3 minutes ago Up 3 minutes (healthy) broker.2.3fij6pt90qt9sb9aco0i2dpys
b888cb6f783a qnib/plain-kafka:1.1.0 "/usr/local/bin/entr…" 3 minutes ago Up 3 minutes (healthy) broker.3.xqmjnfnfg7ha46lf6drlrq4ki
dcdda2d778c2 qnib/plain-kafka:1.1.0 "/usr/local/bin/entr…" 3 minutes ago Up 3 minutes (healthy) broker.1.gtgluxt6q58z2irzgfmu969ba
843def0b24fb qnib/plain-zkui "/usr/local/bin/entr…" 3 minutes ago Up 3 minutes (healthy) zkui.1.7zks618eae8sp4woc7araydix
d7ced19be88c qnib/plain-kafka-manager:2018-04-25 "/usr/local/bin/entr…" 3 minutes ago Up 3 minutes (healthy) manager.1.jdu5gnprhr4d982vz50511rhg
a67ac962e682 qnib/plain-zookeeper:2018-04-25 "/usr/local/bin/entr…" 3 minutes ago Up 3 minutes (healthy) 2181/tcp, 2888/tcp, 3888/tcp zookeeper.1.xar7cmdgozdj79orow0bmj3ev
880121f2fee5 qnib/golang-kafka-producer:2018-05-01.5 "kafka-producer" 3 minutes ago Up 3 minutes (healthy) producer.2.hety8za590v1twdgj2byvrmse
b6487d29812e qnib/golang-kafka-producer:2018-05-01.5 "kafka-producer" 3 minutes ago Up 3 minutes (healthy) producer.1.5oz02c8cw5oefc97xbarq5qoa
8b3a81905e90 qnib/golang-kafka-producer:2018-05-01.5 "kafka-producer" 3 minutes ago Up 3 minutes (healthy) producer.3.p8uh3hzr22fgm7u4gl1p3fiyw
I found I have to use docker service rm to remove the service due to the replicas settings.
The prune command doesn't work against running containers. You will need to either stop or kill them.
docker kill caa0b94c1d98

docker containers shutdown continuously

I follow the official tutorial of deploying docker services https://docs.docker.com/get-started/part5/#add-a-new-service-and-redeploy, in the first time i tried this the containers was running as expected but after that the containers shutdown and restarting (i notice that using the visualizer service provided by docker )
and when i execute the command :
docker stack ps getstartedlab
NAME DESIRED STATE CURRENT STATE
ERROR
getstartedlab_web.1 Running Preparing 2 seconds ago
\_ getstartedlab_web.1 Shutdown Failed 4 minutes ago
"task: non-zero exit (2)"
i read in this post https://github.com/docker/machine/issues/3747 that the problem came from the firewall that may block the icmp, i tried to ping docker.com and i had 100% loss packet but when i ping google.com it's ok with no loss packets.
the result of docker ps --all is :
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9f67c82da7c7 username/repo:tag "python app.py" 2 minutes ago Exited (2) 2 minutes ago getstartedlab_web.2.zcnr0ld9bioy0dffsxmn8zss5
f59e413b0780 username/repo:tag "python app.py" 4 minutes ago Exited (2) 4 minutes ago getstartedlab_web.5.ymxgnsf7n8306yr8963xyyljv
9ab631c4057c username/repo:tag "python app.py" 10 minutes ago Exited (2) 10 minutes ago getstartedlab_web.5.zr3gsvgbyxs8c51fiko5h9jxp
bee5816ce1f2 dockersamples/visualizer:stable "npm start" 15 minutes ago Up 15 minutes 8080/tcp getstartedlab_visualizer.1.oyiqwb5esq6zakcdtiw4txh8a
cadca594f8cd username/repo:tag "python app.py" 24 hours ago Exited (2) 24 hours ago getstartedlab_web.1.zehutsl9cefrccqrj86dz4ap7
576b1a6db0b0 username/repo:tag "python app.py" 24 hours ago Exited (2) 24 hours ago getstartedlab_web.5.za9xvxpo5yvl20kha9sjcimmz
2804ebc4fc0c username/repo:tag "python app.py" 24 hours ago Exited (2) 24 hours ago getstartedlab_web.1.zlk42chspvym3jxkzs2nc8k2d
03efb2b04489 dockersamples/visualizer:stable "npm start" 24 hours ago Exited (255) 16 minutes ago 8080/tcp getstartedlab_visualizer.1.qyp4egtu9vcd31kf2jxtzxko3
b85fd1600955 username/repo:tag "python app.py" 2 days ago Exited (2) 2 days ago getstartedlab_web.5.kzrj3m5c3jgkuox0ulpszizee
and the
docker logs 9f67c82da7c7
python: can't open file 'app.py': [Errno 2] No such file or directory
exuse me for representation of the results of those commands because when i copy past the results the lines breaks, how to copy past and preserve the same displaying ?
can anyone have a fix to this problem ? thanks.

Attach to container

I was surprised when command sudo docker ps -a thrown list of containers:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
efd4879e92e0 ubuntu "/bin/bash" About an hour ago Exited (0) 20 minutes ago elated_newton
7db432be894c ubuntu "/bin/bash" About an hour ago Exited (0) 18 minutes ago nervous_meninsky
aef01293fdc9 ubuntu "/bin/bash" About an hour ago Up About an hour priceless_ramanujan
87cfd461b465 ubuntu "/bin/bash" About an hour ago Up About an hour festive_bhabha
1dcb6f9618d8 ubuntu "/bin/bash" About an hour ago Up About an hour mystifying_poitras
0f1636eb9cc1 hello-world "/hello" About an hour ago Exited (0) About an hour ago sharp_murdock
2a3a1fb03ada hello-world "/hello" About an hour ago Exited (0) About an hour ago admiring_brattain
77c8e7ef5770 hello-world "/hello" 16 hours ago Exited (0) 16 hours ago unruffled_shannon
808805085c59 centos "6.9" 17 hours ago Created youthful_aryabhata
a1438a7811c2 centos "/bin/bash" 17 hours ago Exited (0) 17 hours ago sleepy_neumann
fce6a95f8f5a ubuntu "/bin/bash" 17 hours ago Exited (0) 17 hours ago cranky_ritchie
e17b5f98bbc5 ubuntu "/bin/bash" 17 hours ago Exited (0) 17 hours ago unruffled_ritchie
cafbbe52dad5 hello-world "/hello" 17 hours ago Exited (0) 17 hours ago hungry_pike
d40ac9c16e9c ubuntu "/bin/bash" 17 hours ago Exited (0) 17 hours ago brave_babbage
5efd22250d0e ubuntu "/bin/bash" 17 hours ago Exited (0) 17 hours ago confident_lalande
471e22652bc3 ubuntu "/bin/bash" 17 hours ago Exited (0) 17 hours ago vigorous_wing
b68f43ebae50 ubuntu "bash" 17 hours ago Exited (127) 17 hours ago confident_euler
a83eae486f76 ubuntu "bash" 17 hours ago Exited (0) 17 hours ago infallible_murdock
88b3b4e73e5e hello-world "/hello" 17 hours ago Exited (0) 17 hours ago thirsty_bhabha
deb88e38d347 hello-world "/hello" 17 hours ago Exited (0) 17 hours ago nervous_ptolemy
I was surprised twice when found that some of them alive. Since festive_bhabha is up I would like attach to it:
sudo docker attach festive_bhabha
But command prints nothing and not returns. Why I can't attach to container?
Docker containers are not automatically removed when they exist. You can clean dangling images, exited containers... using:
docker system prune
The Docker container festive_bhabha seems to be an ubuntu image that might not be generating and output, which explains why no output is shown when running the attach command.
You can check what processes are running inside this container by running:
docker container top festive_bhabha
Alternatively, you can exec inside the container.
docker exec -it festive_bhabha bash

Resources