IBM Cloud Code Engine revision fails when deploying standard container with port 80 - ibm-cloud

I am trying to deploy an app in a Code Engine project. The container image is pretty standard: docker.io/library/httpd. All I did in the configuration wizard is to change the port from Code Engine default 8080 to port 80.
Code Engine comes back with:
Revision failed to start with "exit code 1". Check your image and configuration.
In the logs I found these two lines:
(13)Permission denied: AH00072: make_sock: could not bind to address [::]:80
(13)Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80
Why?

I don't know the answer to your question "why", except I see some people on Stackoverflow mention the range up to 1024 is reserved by the OS. I could run my httpd locally on port 80, but in the IBM Code Engine I had to change to 8080.
This is how I managed to get it running:
I edited the httpd.conf as this post implies:
"There is a hint on how to do this at the DockerHub page. An alternative config file must be obtained and added to the container via the Dockerfile.
First get a copy of the config file:
docker run --rm httpd:2.4 cat /usr/local/apache2/conf/httpd.conf > my-httpd.conf
Then edit the my-httpd.conf file and modify the port:
Listen 8080
Finally add to the Dockerfile the instruction to copy it:
COPY ./my-httpd.conf /usr/local/apache2/conf/httpd.conf "

Related

How to start wiremock standalone with custom hostname?

For example, I want to start wiremock standalone with hostname "my.abc.com" with port 9999. Where can I config that? Or what is the right command line options for hostname?
Thanks a lot in advance.
The hostname is determined by DNS or your host file, rather than WireMock itself.
If you want to run everything locally but with a hostname other than localhost you can edit your hosts file and add a line like:
127.0.0.1 api.mydomain.com
Then you can hit a locally running WireMock server on e.g. http://api.mydomain.com:9999/
As agoff points out, if you want to use the Java DSL against the instance you need to configure it:
WireMock.configureFor("api.mydomain.com", 9999);
The host file can be found in the following places:
Windows - c:\Windows\System32\Drivers\etc\hosts
Mac - /private/etc/hosts
*nix - /etc/hosts

awx docker compose phase fails

I am trying to install AWX as part of a docker container image following the guide here but it fails in the docker-compose step like so:
docker-compose -f tools/docker-compose/_sources/docker-compose.yml up --remove-orphans
tools_postgres_1 is up-to-date
tools_redis_1 is up-to-date
Starting tools_awx_1 ...
Starting tools_awx_1 ... error
ERROR: for tools_awx_1 Cannot start service awx_1: driver failed programming external connectivity on endpoint tools_awx_1 (5711eb4a73513b5bd3c27c990761000325f71ae48dbe1e6308d33bf07382415a): Error starting userland proxy: listen tcp4 0.0.0.0:8080: bind: address already in use
ERROR: for awx_1 Cannot start service awx_1: driver failed programming external connectivity on endpoint tools_awx_1 (5711eb4a73513b5bd3c27c990761000325f71ae48dbe1e6308d33bf07382415a): Error starting userland proxy: listen tcp4 0.0.0.0:8080: bind: address already in use
ERROR: Encountered errors while bringing up the project.
make: *** [Makefile:485: docker-compose] Error 1
When I scan for the user of port 8080 it shows this:
$ sudo netstat -pna | grep 8080
tcp6 0 0 :::8080 :::* LISTEN 733/java
This most likely appears to be related to Jenkins since I recollect having installed Jenkins with all default options and I use this port to reach to the Jenkins UI.
So what should be the alternative here without removing Jenkins or changing the port number for the Jenkins daemon (is it a daemon that runs Jenkins btw?) How can I change the endpoint for this AWX docker image? I'm rather new to docker and AWX, not to mention the devops ecosystem in general so would appreciate a bit of context around your suggestions.

"kubectl get pods -A" command not working

I installed Kubernetes in virtual BOX previously it was working properly but not it is showing The connection to the server 192.168.42.141:6443 was refused - did you specify the right host or port?, Please help.
The connection to the server 192.168.42.141:6443 was refused - did you specify the right host or port?
According to issue there might be kube-apiserver not running state. To check the apiserver status run following command
$ docker ps
# If above is not sowing apiserver container, then it is stopped, To see the stopped container run
$ docker ps -a
P.S: From the comment there is also a version mismatch. To update kubectl follow this
kubectl on any machine reads the current context from kubeconfig file. The file is located at the path $USER_HOME/.kube/config
There are clusters configured inside this file alongwith the IP or domain name of the cluster. If the IP is invalid or not reachable OR the domain name can not be resolved and is unreachable OR the config file is corrupted or the config file is empty, then this error occurs.
In brief, you need to check your config file. It will save you a lot of effort.

How to make a TCP outgoing connection with Docker container?

My Go application makes TLS connections via tls.Dial() to exchange data.
It works fine when run from the host:
But the outgoing connection doesn't seem to work when the app is run from a Docker container. The app hangs indefinitely.
Note 1: Same behavior with using docker run -p $(docker-machine ip):2500:2500 ...
Note 2: VM doesn't have extra port forwarding settings other than the default settings that came with docker-machine's default VM.
Docker image build with Dockerfile:
FROM golang:latest
RUN mkdir -p "$GOPATH/src/path/to/app"
# Install dependencies
RUN go get github.com/path/to/dep
VOLUME "$GOPATH/src/path/to/app"
EXPOSE 2500
WORKDIR "$GOPATH/src/path/to/app"
CMD ["go", "run", "main.go"]
Host is OS X running docker-machine.
Question
How can I make the TCP outgoing connection to work?
You are either using boot2docker or docker-machine (since you are running docker on OSX). If you are using boot2docker, you have to forward the ports on VirtualBox as well as docker, have a look at this blog post:
https://fogstack.wordpress.com/2014/02/09/docker-on-osx-port-forwarding/
If you are using docker-machine, you have to connect to the docker-machine assigned ip, not localhost, have a look at this post:
https://github.com/docker/machine/issues/710
I see now that you are using docker-machine specifically, so the post about docker-machine should answer your question.
Edit: I misunderstood the question. You are trying to make an outgoing connection on a forwarded port. That is not correct. By default docker can make outgoing connections on any port. The port forwarding is for incoming connections only. Please try again without specifying any ports to forward. My suspicion is that you are trying to make an outgoing connection on the incoming (forwarded) port.
I've just had exactly the same problem. Was unable to connect out at all.
Restarted the container, and suddenly outgoing connections worked fine. It's possible that the container survived an update of docker?
Currently using Docker version 18.09.3, build 774a1f4

How do I stop Apache/Tomcat server on localhost://8080?

I keep getting errors when trying to serve files locally. I am using Tomcat on port 8080.
When using Eclipse, I get the following error message:
Several ports (8080, 8009) required by Tomcat v8.0 Server at localhost are already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).
Question
How do I stop the server on port 8080 if I don't know which process started it?
Try to go with a web browser to:
localhost:8080 or 127.0.0.1:8080
and
localhost:8009 or 127.0.0.1:8009
There you could see which service is running on those ports.
Then it will be more simple to understand what you have to stop.
EDIT:
You could use a prompt and the command:
netstat -b
-b it will show the name of the executable running on a port.
For understanding how it works here a good explanation.