Docker Local Registry run from different port - docker

I installed Docker Local Registry as below
docker pull registry
after
docker run -d -p 5001:5001 -v C:/localhub/registry:/var/lib/registry --restart=always --name hub.local registry
because of 5000 port using another application.
but i can't reach to
http://localhost:5001/v2/_catalog

The first part of the -p value is the host port and the second part is the port within the container.
This code runs the registry on port 5001
docker run -d -p 5001:5000 --name hub.local registry
If you want to change the port the registry listens on within the container, you must use this code
docker run -d -e REGISTRY_HTTP_ADDR=0.0.0.0:5001 -p 5001:5001 --name hub.local registry

'''
docker run -d -p 5001:5000 -v C:/localhub/registry:/var/lib/registry --restart=always --name hub.local registry
'''
Keep the internal port the same and change only your local port

Related

Access NGINX container in a different network on VM from host machine

I have created three networks A, B and C using docker on a ubuntu VM, each network contained the three containers 2 busybox and 1 nginx. Each nginx container in different network i have port-forwarded on 80 81 and 82 respectively using below commands:
sudo docker run -itd --rm -p 82:82 --network C --name web3 nginx
sudo docker run -itd --rm -p 81:81 --network B --name web2 nginx
sudo docker run -itd --rm -p 80:80 --network A --name web1 nginx
but when i tried to access the container from my host machine providing the ip address of my vm along with port e.g. https://192.168.18.240:82 it does not give access to that container in different network. While giving the only IP address with port 80 am able to access the nginx but not on port 82 and 81. I have cleared the cache and clear the browsing history but all in vain.
All of the docker nginx containers listen on port 80. You are mapping B and C to the wrong container port.
sudo docker run -itd --rm -p 82:**80** --network C --name web3 nginx
sudo docker run -itd --rm -p 81:**80** --network B --name web2 nginx
sudo docker run -itd --rm -p 80:80 --network A --name web1 nginx

Remote access to cassandra 4.0.1 using docker via cqlsh

My Environment:
Windows 10 Home
WSL2
Cassandra 4.0.1: Official Docker Image
Docker command:
docker run --name cassandra-node-0 -p 7000:7000 -p 7001:7001 -p 7199:7199 -p 9042:9042 -p 9160:9160 -e CASSANDRA_CLUSTER_NAME=MyCluster -e CASSANDRA_ENDPOINT_SNITCH=GossipingPropertyFileSnitch -e CASSANDRA_DC=datacenter1 -e CASSANDRA_BROADCAST_ADDRESS=192.168.1.101 -d cassandra
CQLSH Command:
docker run -it -e CQLSH_HOST=$(docker inspect --format='{{ .NetworkSettings.IPAddress}}' cassandra-node-0) --name cassandra-client --entrypoint=cqlsh cassandra
I try to connect cassandra node using cqlsh where ubuntu in WSL2 in same pc.
I did not change all *.yaml file and only use Docker Env.
When I insert node's docker network ip to CQLSH_HOST, cqlsh is successfully connected node.
But, When I insert my private ip, public ip or 127.0.0.1, cqlsh is refused connection to node.
This shows the same issue when nodes from different networks connect.
I think I'm missing a setting of something Docker Env.
What settings am I missing?
[Update] I add some port fowarding rules in firewall but same issue.
[Update 2] docker ps -a result:
0.0.0.0:7000-7001->7000-7001/tcp, :::7000-7001->7000-7001/tcp, 0.0.0.0:7199->7199/tcp, :::7199->7199/tcp, 0.0.0.0:9042->9042/tcp, :::9042->9042/tcp, 0.0.0.0:9160->9160/tcp, :::9160->9160/tcp
Try adding --hostname and --network when you run Cassandra. For example:
$ docker run --rm -d
--name cassandra-node-0
--hostname cassandra-node-0
--network cassandra-node-0
You'll find that it's easier to connect via cqlsh by adding:
--network cassandra-node-0
-e CQLSH_HOST=cassandra-node-0
to your docker run command. Cheers!

Can we run docker inside a docker container which is running in a virtual-box of Ubuntu 18.04?

I want to run docker inside another docker container. My main container is running in a virtualbox of OS Ubuntu 18.04 which is there on my Windows 10. On trying to run it, it is showing me as:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
How can I resolve this issue?
Yes, you can do this. Check for dind (docker in docker) on docker webpage how to achieve it: https://hub.docker.com/_/docker
Your error indicates that either dockerd in the top level container is not running or you didn't mount docker.sock on the dependent container to communicate with dockerd running on your top-level container.
I am running electric-flow in a docker container in my Ubuntu virtual-box using this docker command: docker run --name efserver --hostname=efserver -d -p 8080:8080 -p 9990:9990 -p 7800:7800 -p 7070:80 -p 443:443 -p 8443:8443 -p 8200:8200 -i -t ecdocker/eflow-ce. Inside this docker container, I want to install and run docker so that my CI/CD pipeline in electric-flow can access and use docker commands.
From your above description, ecdocker/eflow-ce is your CI/CD solution container, and you just want to use docker command in this container, then you did not need dind solution. You can just access to a container's host docker server.
Something like follows:
docker run --privileged --name efserver --hostname=efserver -d -p 8080:8080 -p 9990:9990 -p 7800:7800 -p 7070:80 -p 443:443 -p 8443:8443 -p 8200:8200 -v $(which docker):/usr/bin/docker -v /var/run/docker.sock:/var/run/docker.sock -i -t ecdocker/eflow-ce
Compared to your old command:
Add --privileged
Add -v $(which docker):/usr/bin/docker, then you can use docker client in container.
Add -v /var/run/docker.sock:/var/run/docker.sock, then you can access host's docker daemon using client in container.

Link containers to a running container

I want to know if I can link Docker containers to a running container. I am running this command on a server:
docker run -d -u jenkins --name appdev-jenkins --network=host --memory="8g" -p 80:8080 -p 443:443 -p 50000:50000 -v "/opt/jenkins":/var/jenkins_home -v /var/run/docker.sock:/var/run/docker.sock jenkinsci/blueocean
I want to be able to link another Jenkins instance as an agent to the original Jenkins instance. Is this possible?
Have you tried the following?
docker run -d --link appdev-jenkins --name second-jenkins [other params]

Docker expose port

Could I expose different docker container points to the same HTTP port on the host?
Example
docker container run --publish 80:80 -d -it --name wp wordpress
docker container run --publish 90:80 -d -it --name ci jenkins
docker container run --publish 100:80 -d -it --name gitlab gitlab/gitlab-ce
With that commands you are not using the same port at host. The nomenclature for -pis "hostPort:containerPort" so in that way you are mapping container's port 80 from all of them to your host at ports 80, 90 and 100. So no conflict at all.
Anyway, to answer to your question about possible conflicting. In first instance, your commands should be:
docker container run --publish 80:80 -d -it --name wp wordpress
docker container run --publish 80:80 -d -it --name ci jenkins
docker container run --publish 80:80 -d -it --name gitlab gitlab/gitlab-ce
In this way, you can do that commands but you'll probably get an error saying Bind for 0.0.0.0:80 failed: port is already allocated..
Anyway, in the hypothetical case of docker allowing that without an error...
The first one you map is which is going to work because on "docker run" command there are iptables commands for openning ports from container to host, and iptables rules work in "first matching is which works" style. So you'll have 3 iptables rules in this case but the one is going to work is the first.

Resources