#Port 8983 is already being used by another process# - docker

I was able to run SOLR 7.x in my Apple M1 chip Mac without any issues.
We recently moved from SOLR 7.x to SOLR 8.x
Now the below command throws this error consistently,
#Command: #
**docker run --name solr bitnami/solr:latest**
#Error:#
Port 8983 is already being used by another process
Info for you:
-----------
I create Solr docker image based out of docker.io/bitnami/solr:8.11.1
#Below commands gives empty output in mac terminal,#
lsof -i tcp:8983
lsof -i :8983
#Command: #
telnet localhost 8983
#Output:#
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host
Docker file:
------------
FROM docker.io/bitnami/solr:8.11.1
.
.
.
RUN mkdir -p $SOLR_HOME/home/primary/conf
RUN mkdir -p $SOLR_HOME/home/reindex/conf
RUN mkdir -p $SOLR_HOME/home/primary/data
RUN mkdir -p $SOLR_HOME/home/reindex/data
COPY ./primary/core.properties $SOLR_HOME/home/primary/
COPY ./primary/custom.properties $SOLR_HOME/home/primary/
COPY ./conf/* $SOLR_HOME/home/primary/conf/
COPY ./reindex/core.properties $SOLR_HOME/home/reindex/
COPY ./reindex/custom.properties $SOLR_HOME/home/reindex/
COPY ./conf/* $SOLR_HOME/home/reindex/conf/
USER root
RUN apt-get update && apt-get upgrade -y && rm -rf /var/lib/apt/lists/*
.
.
.
EXPOSE 8983
This Apple M1 chip, Docker, SOLR 8.11.1 combination error is very strange. Any help is greatly appreciated.

Related

TCP/Telnet from inside docker container

I have a 'mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim' Docker container, with 2 things on it:
-a custom SDK running on it
-a dotnet5 application that connects to the SDK with TCP
If I connect the the Docker's bash, I can use telnet localhost 54321 to connect to my SDK successfully
If I run the Windows SDK version on my development computer (Windows), and I run my application IIS Express instead of Docker, I can successfully connect with a telnet library (host 'localhost', port '54321'), this works
However, I want to run both the SDK and my dotnet application in a Docker container, and when I try to connect from inside the container (the same thing that works on the IIS hosted version), this does not work. By running 'telnet localhost 54321' from the docker container commandline I can confirm that the SDK is running. What am I doing wrong?
Dockerfile:
FROM mcr.microsoft.com/dotnet/aspnet:5.0-buster-slim AS base
RUN apt-get update && apt-get install -y telnet
RUN apt-get update && apt-get install -y libssl1.1
RUN apt-get update && apt-get install -y libpulse0
RUN apt-get update && apt-get install -y libasound2
RUN apt-get update && apt-get install -y libicu63
RUN apt-get update && apt-get install -y libpcre2-16-0
RUN apt-get update && apt-get install -y libdouble-conversion1
RUN apt-get update && apt-get install -y libglib2.0-0
RUN mkdir /sdk
COPY ["Server/Sdk/SomeSDK*", "sdk/"]
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/sdk:5.0 AS build
WORKDIR /src
COPY ["Server/MyProject.Server.csproj", "Server/"]
COPY ["Shared/MyProject.Shared.csproj", "Shared/"]
COPY ["Client/MyProject.Client.csproj", "Client/"]
RUN dotnet restore "Server/MyProject.Server.csproj"
COPY . .
WORKDIR "/src/Server"
RUN dotnet build "MyProject.Server.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MyProject.Server.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyProject.Server.dll"]
Code (working on IIS, when SDK is running on Windows, but not when both SDK and code are running inside the same Docker container):
var telnetClient = new TelnetClient("localhost", 54321, TimeSpan.FromSeconds(1), new CancellationToken());
await telnetClient.Connect();
Thread.Sleep(2000);
await telnetClient.Send("init");
Command line (working BOTH from windows CLI, and from Docker bash (so also when the code is not working, this is working):
$telnet localhost 54321
$init
The issue might be (but I'm not sure, as I've received this result from using direct command line '$telnet localhost 54321' from within dotnet: 'telnet: connection refused by remote host'
Make sure you use in your docker run command also --network=host to use the same network if you want to reach out of the container or create a bridge with --network=bridge (for example with another container).
By default the Docker container is spawn on a separate, dedicated and private subnet on your machine (mostly 172.17.0.0/16) which is different from your machine's default/local subnet (127.0.0.0/8).
For connecting into the host's subnet in this case 127.0.0.0/8 you need --network=host. For communication within the same container though it's not necessary and works out of the box.
For accessing the service in container from the outside you need to make sure you have your application's port published either with --publish HOST_PORT:DOCKER_PORT or --publish-all (random port(s) on host are then assigned, check with docker ps).
Host to container (normal)
# host
telnet <container's IP> 8000 # connects, typing + return shows in netcat stdout
# container
docker run --rm -it --publish 8000:8000 alpine nc -v -l -p 8000
Container to host (normal)
# host
nc -v -l -p 8000
# container, docker run -it alpine
apk add busybox-extras
telnet localhost 8000 # hangs, is dead
Container to host (on host network)
# host
nc -v -l -p 8000
# container, docker run -it --network=host alpine
apk add busybox-extras
telnet localhost 8000 # connects, typing + return shows in netcat stdout
Within container
# start container
docker run -it --name alpine alpine
apk add busybox-extras
# exec into container to create service on 4000
docker exec -it alpine nc -v -l -p 4000
# exec into container to create service on 5000
docker exec -it alpine nc -v -l -p 5000
# telneting from the original terminal (the one with apk add)
telnet localhost 4000 # connects, works
telnet localhost 5000 # connects, works

Docker Toolbox refused to connect on the browser - Tried different solutions - Windows 7

I have installed Docker Toolbox on Windows 7.
Everything has been installed correctly.
Now I try to build and run a DockerFile.
Dockerfile
FROM debian:9
RUN apt-get update -yq \
&& apt-get install curl gnupg -yq \
&& curl -sL https://deb.nodesource.com/setup_10.x | bash \
&& apt-get install nodejs -yq \
&& apt-get clean -y
ADD . /app/
WORKDIR /app
RUN npm install
VOLUME /app/logs
CMD npm run start
After successfully running the command line docker build -t test . and docker run -it -d -p 3306:3306 test, I try to access it via my browser by doing :
http://192.168.99.100:3306
which correspond to http://[docker-machine-ip]:port
But it refuses to connect.
After searching on the internet, I tried several solutions:
1. Use the container IP
docker inspect --format '{{ .NetworkSettings.IPAddress }}' [id]
http://[containerIP]:port
2. Add port forwarding on Oracle VM defaut machine
VirtualBox -> Machine settings -> Network -> Adapter 1 (NAT) -> Advanced, Port Forwarding
name : test
Host ip : 127.0.0.1
Host port : 3306
Guest port : 3306
I even tried by putting Guest IP to 192.168.99.100 and letting Host IP to empty.
3. Try different ports
I tried differents ports to see if it was not caused by a port already opened.
I even tried the option --publish-all (-P) but as a result, I don't have any ports showing on docker ps -a
docker run -it -d -P test
4. Deactivate the windows firewall
Both public and private.
None of those solutions worked for me and I don't know what to do next.
Any help ? I would appreciate. Thank you.

Can't access docker containers from host

I have a simple image for a Rails service with the following Dockerfile:
FROM ruby:2.4.4
MAINTAINER sadzid.suljic#gmail.com
RUN apt-get update && apt-get install -y \
build-essential \
nodejs
RUN mkdir /app
WORKDIR /app
COPY Gemfile Gemfile.lock ./
RUN gem install bundler && bundle install
COPY . ./
EXPOSE 3000
CMD ["rails", "s", "-p", "3000"]
I built the image and ran the container with these commands:
docker build -t chat/users .
docker run -P --name users_service chat/users
I have this output on the host:
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
23716591e656 chat/users "rails s -p 3000" 6 minutes ago Up 5 minutes 0.0.0.0:32774->3000/tcp users_service
$ lsof -n -i :32774 | grep LISTEN
com.docke 32891 ssuljic 18u IPv4 0x41c034d5d4627f5f 0t0 TCP *:filenet-re (LISTEN)
com.docke 32891 ssuljic 19u IPv6 0x41c034d5d3beb9b7 0t0 TCP [::1]:filenet-re (LISTEN)
$ curl localhost:32774
curl: (52) Empty reply from server
When I run curl localhost:3000 inside the container I get the proper response from my API.
Does anyone know why I can't access the container from my host?
I'm using Docker for Mac with this version:
$ docker -v
Docker version 18.03.1-ce, build 9ee9f40
Some versions of Rails bind to localhost by default, which explains why you can access from within the container but not from the host (it’s viewed as a different host).
Adding -b 0.0.0.0 to the CMD instruction should solve the problem.
Try:
docker run -p 3000:3000 --name users_service chat/users
This will map 3000 to 3000
http://localhost:3000
Looking into this more I think this was either and chrome issue or network issue as I was having the same issue:
Here is how I resolved it:
Make sure your /etc/hosts file has 127.0.0.1 localhost (more than likely it's already there)
Cleared Cookies and Cached files
Cleared host cache
Go to:chrome://net-internals/#dns click Clear Host Cache
Restarted chrome
Reset Network Adapter
Note: This was unintentional so not sure if it was part of the fix or not, but wanted to include it in case.
Unfortunately I'm not sure which step fixed the problem

Rails app docker container not accessible from Windows host

I am trying to make a simple docker container that runs the Rails app from the directory that I launch it in.
Everything appears to be fine except when I run the container and try to access it from my Windows host at the IP address that Docker Machine gives me, it responds with a connection refused error message.
I even used the Nginx Dockerfile as a reference, because the Nginx Dockerfile actually builds a container that is accessible for me.
Here is my Dockerfile so far:
FROM ruby:2.3.1
RUN gem install rails && \
apt-get update -y && \
apt-get install -y nodejs
VOLUME ["/web_app"]
ADD . /web_app
WORKDIR /web_app
RUN bundle install
CMD rails s -p 80
EXPOSE 80
I build the image using this command
docker build -t rails_server .
I then run it using this command
docker run -d -p 80:80 rails_server
And here is what I try to access the webpage:
curl $(docker-machine ip)
And this is what I get back:
curl: (7) Failed to connect to 192.168.99.100 port 80: Connection refused
And this is how it makes me feel:
The problem here seems to be that the app is listening on 127.0.0.1:80, so the service will not accept connection from outside the container. Could you check if modifying the rails server to listening on 0.0.0.0 the issue solves?
You can do that using the -b flag of rails s:
FROM ruby:2.3.1
RUN gem install rails && \
apt-get update -y && \
apt-get install -y nodejs
VOLUME ["/web_app"]
ADD . /web_app
WORKDIR /web_app
RUN bundle install
CMD rails s -b 0.0.0.0 -p 80
EXPOSE 80
The port is only exposed to the vm running the docker inside. You have to still expose port 80 of your vm to your local machine so it can connect to it. I think the best approach is making your container to be listened o an optional port like 7070 and then using a simple nginx proxy pass to feed the content to the outside (listening on port 80)

Can't map ports between host and a Docker container on OSX

I have tried to follow some instructions on GitHub
to set up the port forwarding but I have no luck. Would you please help? I built the container following an example in a book and here is the Dockerfile:
FROM ubuntu:14.04
RUN apt-get update
RUN apt-get install -y nginx
RUN echo 'Hi, I am in your container' > /usr/share/nginx/html/index.html
EXPOSE 8000
Steps taken:
$ boot2docker stop
$ VBoxManage modifyvm "boot2docker-vm" --natpf1 delete forwardHostPort8000ToDockerVM
$ VBoxManage modifyvm "boot2docker-vm" --natpf1 "forwardHostPort8000ToDockerVM,tcp,,8000,,8000"
$ boot2docker start
$ docker run -d -p 127.0.0.1:8000:8000 --name static_web static_web \nginx -g "daemon off;"
122ba8949685ce91b84890656c399b19028cb2e8a7e8be3d4a19122eba9ab592
This is the result:
$ curl 127.0.0.1:8000
curl: (52) Empty reply from server
$ telnet 127.0.0.1 8000
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host
Note:
If I don't bind it to the 127.0.0.1 interface (i.e, only -p 8000:8000), then it will work with my VM’s IP:
$ curl 192.168.59.103:8000
Hi, I am in your container
Env:
$ boot2docker -v
Boot2Docker-cli version: v1.3.1
Git commit: 57ccdb8
$ docker -v
Docker version 1.3.1, build 4e9bbfa
I'm using VirtualBox version 4.3.20 running under OS X 10.10.1.
It is actually a bug on my side. I exposed port 8000 in the Dockerfile; however, I haven't changed the setting in nginx. So, I changed it back to port 80 and started the container as followed, and it worked. Now I can hit it with a browser on another machine.
docker run -d -p 8000:80 --name static_web static_web \nginx -g "daemon off;"

Resources