Can't access docker from public IP - docker

So I try running some docker application on My local network it works fine without any problem.
But when I try access it from public IP address it doesn't allow Me to connect
Ex: http://SomePublicIp then browser return with
SSH-2.0-OpenSSH_8.4p1 Debian-5+deb11u1
but when I try with local IP it works normally
the return of docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS
NAMES
yacht
352d4a07c5aa ghcr.io/ajnart/homarr:latest "docker-entrypoint.s…" 13 hours ago Up 13 hours 0.0.0.0:7575->7575/tcp, :::7575->7575/tcp
Homepage
8ba96af5b79b linuxserver/sickgear:latest "/init" 13 hours ago Up 13 hours 0.0.0.0:8081->8081/tcp, :::8081->8081/tcp
sickgear
cb50149d8921 n8nio/n8n:latest "tini -- /docker-ent…" 13 hours ago Up 13 hours 0.0.0.0:5678->5678/tcp, :::5678->5678/tcp
n8n
86d99e6877cc portainer/portainer-ce:latest "/portainer" 14 hours ago Up 13 hours 0.0.0.0:8000->8000/tcp, :::8000->8000/tcp, 0.0.0.0:9443->9443/tcp, :::9443->9443/tcp, 9000/tcp
portainer
4bc1c1c244a1 linuxserver/homeassistant:latest "/init" 2 days ago Up 14 hours
HomeAssistant
b712b08105c7 grafana/grafana:8.4.5 "/run.sh" 4 days ago Up 14 hours 0.0.0.0:41117->3000/tcp, :::41117->3000/tcp
Smokeping
8b98f0161300 linuxserver/syncthing:latest "/init" 4 days ago Up 14 hours 0.0.0.0:8384->8384/tcp, 0.0.0.0:21027->21027/udp, :::8384->8384/tcp, :::21027->21027/udp, 0.0.0.0:22000->22000/tcp, :::22000->22000/tcp, 0.0.0.0:22000->22000/udp, :::22000->22000/udp
Syncthing
a0622f05ac9f nodered/node-red:2.2.2-12 "npm --no-update-not…" 10 days ago Up 14 hours (healthy) 0.0.0.0:1880->1880/tcp, :::1880->1880/tcp

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

Docker info shows containers but docker container ls doesn't

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

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

Localhost Registry in Kubernetes - distribute certificates

I am running Docker for Mac(Edge) and I have a Kubernetes Cluster.
I am trying to be able to run a Registry inside Kubernetes, so I can push images to the cluster and use them in a Localhost environment.
I have installed a Registry with Helm: helm install stable/docker-registry
And I am able to run with portforward:
export POD_NAME=$(kubectl get pods --namespace default -l "app=docker-registry,release=guiding-hedgehog" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl port-forward $POD_NAME 8080:5000
The problem is that I get an error when trying to push to the registry with docker push localhost:5000/hello:
The push refers to repository [localhost:5000/hello]
Get http://localhost:5000/v2/: dial tcp [::1]:5000: getsockopt: connection refused
kubectl get services:
NAME: eyewitness-moose-docker-registry TYPE: ClusterIP CLUSTER-IP:10.106.213.130 EXTERNAL-IP:<none> PORT(S):5000/TCP
Note: Also tried adding docker.for.mac.localhost:5000 to list of insecure registries.
So it looks like a security issue, and might be related to that it is not possible to run an insecure registry described in Docker doc
Therefore I have created a certificate as described here.
Now the question is, how do I distribute the certificate to each node with only kubectl?
Note: I am running in Docker for Mac(Edge), so I can get to the Kubernetes running containers. But there is so many and how and I don't think that is is the right way:
7d50a16271b5 gcr.io/kubernetes-helm/tiller "/tiller" 19 hours ago Up 19 hours k8s_tiller_tiller-deploy-865dd6c794-j7nk8_kube-system_8cbf6a09-329d-11e8-83ed-025000000001_0
6c77c450b374 gcr.io/google_containers/pause-amd64:3.0 "/pause" 19 hours ago Up 19 hours k8s_POD_tiller-deploy-865dd6c794-j7nk8_kube-system_8cbf6a09-329d-11e8-83ed-025000000001_0
ff19b2587142 docker/kube-compose-controller "/compose-controller…" 40 hours ago Up 40 hours k8s_compose_compose-5d4f4d67b6-n9jbp_docker_d7fc0ef4-3065-11e8-b9f8-025000000001_0
22109b6207af docker/kube-compose-api-server "/api-server --kubec…" 40 hours ago Up 40 hours k8s_compose_compose-api-7bb7b5968f-9mjxr_docker_d7f23906-3065-11e8-b9f8-025000000001_0
fd35236592f2 gcr.io/google_containers/k8s-dns-sidecar-amd64 "/sidecar --v=2 --lo…" 40 hours ago Up 40 hours k8s_sidecar_kube-dns-6f4fd4bdf-h25hz_kube-system_ba973aaa-3065-11e8-b9f8-025000000001_0
8df955fd61f4 gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64 "/dnsmasq-nanny -v=2…" 40 hours ago Up 40 hours k8s_dnsmasq_kube-dns-6f4fd4bdf-h25hz_kube-system_ba973aaa-3065-11e8-b9f8-025000000001_0
2b35fb82f6e6 gcr.io/google_containers/k8s-dns-kube-dns-amd64 "/kube-dns --domain=…" 40 hours ago Up 40 hours k8s_kubedns_kube-dns-6f4fd4bdf-h25hz_kube-system_ba973aaa-3065-11e8-b9f8-025000000001_0
89b4e3ccccd5 gcr.io/google_containers/pause-amd64:3.0 "/pause" 40 hours ago Up 40 hours k8s_POD_compose-5d4f4d67b6-n9jbp_docker_d7fc0ef4-3065-11e8-b9f8-025000000001_0
d5a6a2ba714b gcr.io/google_containers/pause-amd64:3.0 "/pause" 40 hours ago Up 40 hours k8s_POD_kube-dns-6f4fd4bdf-h25hz_kube-system_ba973aaa-3065-11e8-b9f8-025000000001_0
608c82a39845 gcr.io/google_containers/pause-amd64:3.0 "/pause" 40 hours ago Up 40 hours k8s_POD_compose-api-7bb7b5968f-9mjxr_docker_d7f23906-3065-11e8-b9f8-025000000001_0
38982ea53b7d gcr.io/google_containers/kube-proxy-amd64 "/usr/local/bin/kube…" 40 hours ago Up 40 hours k8s_kube-proxy_kube-proxy-75vvn_kube-system_bace7415-3065-11e8-b9f8-025000000001_0
1e5b99acf1ca gcr.io/google_containers/pause-amd64:3.0 "/pause" 40 hours ago Up 40 hours k8s_POD_kube-proxy-75vvn_kube-system_bace7415-3065-11e8-b9f8-025000000001_0
e75f4b1db79e gcr.io/google_containers/kube-scheduler-amd64 "kube-scheduler --ku…" 40 hours ago Up 40 hours k8s_kube-scheduler_kube-scheduler-docker-for-desktop_kube-system_f851ca949bc3883a8c73ea5debfa5def_0
2834798acbc5 gcr.io/google_containers/kube-apiserver-amd64 "kube-apiserver --ad…" 40 hours ago Up 40 hours k8s_kube-apiserver_kube-apiserver-docker-for-desktop_kube-system_caae2ec94c5b9fe55a01978c5b2f561e_0
91cb9c57c7f6 gcr.io/google_containers/etcd-amd64 "etcd --listen-clien…" 40 hours ago Up 40 hours k8s_etcd_etcd-docker-for-desktop_kube-system_7278f85057e8bf5cb81c9f96d3b25320_0
ead556edb234 gcr.io/google_containers/kube-controller-manager-amd64 "kube-controller-man…" 40 hours ago Up 40 hours k8s_kube-controller-manager_kube-controller-manager-docker-for-desktop_kube-system_81fd91d1cb0957bc579d5dd888f73ead_0
bd4e94136fe5 gcr.io/google_containers/pause-amd64:3.0 "/pause" 40 hours ago Up 40 hours k8s_POD_kube-scheduler-docker-for-desktop_kube-system_f851ca949bc3883a8c73ea5debfa5def_0
45f2657c47a7 gcr.io/google_containers/pause-amd64:3.0 "/pause" 40 hours ago Up 40 hours k8s_POD_kube-controller-manager-docker-for-desktop_kube-system_81fd91d1cb0957bc579d5dd888f73ead_0
3e5a8064e983 gcr.io/google_containers/pause-amd64:3.0 "/pause" 40 hours ago Up 40 hours k8s_POD_etcd-docker-for-desktop_kube-system_7278f85057e8bf5cb81c9f96d3b25320_0
b7ae16f4ce6b gcr.io/google_containers/pause-amd64:3.0 "/pause" 40 hours ago Up 40 hours k8s_POD_kube-apiserver-docker-for-desktop_kube-system_caae2ec94c5b9fe55a01978c5b2f561e_0
Anything in the right direction is welcome.
Thanks in advance

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