apache2: Permission denied: AH00072: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down
Asked Answered
D

1

5

I am trying a very simple tutorial explaining how convert docker-compose to minishift ( Minishift and Kompose. I tried to converted and push the docker-compose.yml example

version: "2"

services:

  redis-master:
    image: k8s.gcr.io/redis:e2e 
    ports:
      - "6379"

  redis-slave:
    image: gcr.io/google_samples/gb-redisslave:v1
    ports:
      - "6379"
    environment:
      - GET_HOSTS_FROM=dns

  frontend:
    image: gcr.io/google-samples/gb-frontend:v4
    ports:
      - "80:80"
    environment:
      - GET_HOSTS_FROM=dns
    labels:
      kompose.service.type: LoadBalancer

I successfully compose and push as I can see from these logs:

C:\Users\Cast\docker-compose-to-minishift>kompose-windows-amd64 up --provider=openshift
[36mINFO[0m We are going to create OpenShift DeploymentConfigs, Services and PersistentVolumeClaims for your Dockerized application.
If you need different kind of resources, use the 'kompose convert' and 'oc create -f' commands instead.

[36mINFO[0m Deploying application in "myproject" namespace
[36mINFO[0m Successfully created Service: frontend
[36mINFO[0m Successfully created Service: redis-master
[36mINFO[0m Successfully created Service: redis-slave
[36mINFO[0m Successfully created DeploymentConfig: frontend
[36mINFO[0m Successfully created ImageStream: frontend
[36mINFO[0m Successfully created DeploymentConfig: redis-master
[36mINFO[0m Successfully created ImageStream: redis-master
[36mINFO[0m Successfully created DeploymentConfig: redis-slave
[36mINFO[0m Successfully created ImageStream: redis-slave

Your application has been deployed to OpenShift. You can run 'oc get dc,svc,is,pvc' for details.

C:\Users\Cast\docker-compose-to-minishift>oc get dc
NAME           REVISION   DESIRED   CURRENT   TRIGGERED BY
frontend       0          1         0         config,image(frontend:v4)
redis-master   1          1         1         config,image(redis-master:e2e)
redis-slave    1          1         1         config,image(redis-slave:v1)

Nevertheless, I couldn't reach the web application and looking at the logs I found "The container frontend is crashing frequently. It must wait before it will be restarted again" and clicking in details:

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.0.13. Set the 'ServerName' directive globally to suppress this message
(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
no listening sockets available, shutting down
AH00015: Unable to open logs

Searching around I found someone suggestion to change from port 80 to some not root privileged port (eg. 8080). So I changed it in my docker-compose, deleted manualy the namespace myproject, recreated it in OpenShift Web Console and I tried to run once again. Exactly same exception with same message.

In case it is relevant, I have another cmd window with

C:\Users\Cast\docker-compose-to-minishift>kubectl proxy --port=8080
Starting to serve on 127.0.0.1:8080

I am quite begginer on moving from docker-compose to minishift (first time using Kompose tool to be honest).

My main question: why I still get same issue if I have alread changed the ports from 80:80 to 8080:8080 in docker-compose

  frontend:
    image: gcr.io/google-samples/gb-frontend:v4
    ports:
      - "8080:8080"

Secondary question: what I have to check to see why I can't start the pront-end service? It is quite limited the exception provided.

*** edited

converted docker-compose by kompose (only front-end files)

frontend-imagestream

apiVersion: v1
kind: ImageStream
metadata:
  creationTimestamp: null
  labels:
    io.kompose.service: frontend
  name: frontend
spec:
  tags:
  - annotations: null
    from:
      kind: DockerImage
      name: gcr.io/google-samples/gb-frontend:v4
    generation: null
    importPolicy: {}
    name: v4
status:
  dockerImageRepository: ""

frontend-service

apiVersion: v1
kind: Service
metadata:
  annotations:
    kompose.cmd: C:\tools\kompose-windows-amd64.exe convert --provider=openshift
    kompose.service.type: LoadBalancer
    kompose.version: 1.19.0 (f63a961c)
  creationTimestamp: null
  labels:
    io.kompose.service: frontend
  name: frontend
spec:
  ports:
  - name: "8080"
    port: 8080
    targetPort: 8080
  selector:
    io.kompose.service: frontend
  type: LoadBalancer
status:
  loadBalancer: {}

frontend-deploymentconfig

apiVersion: v1
kind: DeploymentConfig
metadata:
  annotations:
    kompose.cmd: C:\tools\kompose-windows-amd64.exe convert --provider=openshift
    kompose.service.type: LoadBalancer
    kompose.version: 1.19.0 (f63a961c)
  creationTimestamp: null
  labels:
    io.kompose.service: frontend
  name: frontend
spec:
  replicas: 1
  selector:
    io.kompose.service: frontend
  strategy:
    resources: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        io.kompose.service: frontend
    spec:
      containers:
      - env:
        - name: GET_HOSTS_FROM
          value: dns
        image: ' '
        name: frontend
        ports:
        - containerPort: 8080
        resources: {}
      restartPolicy: Always
  test: false
  triggers:
  - type: ConfigChange
  - imageChangeParams:
      automatic: true
      containerNames:
      - frontend
      from:
        kind: ImageStreamTag
        name: frontend:v4
    type: ImageChange
status: {}

Added all logs (I removed Redis and left only FrontEnd service since it was the only causing issue):

Windows PowerShell
Copyright (C) Microsoft Corporation. Todos os direitos reservados.

Experimente a nova plataforma cruzada PowerShell https://aka.ms/pscore6

PS C:\Windows\system32> cd C:\to_learn\docker-compose-to-minishift\first-try
PS C:\to_learn\docker-compose-to-minishift\first-try> kompose-windows-amd64 up --provider=openshift
[36mINFO[0m We are going to create OpenShift DeploymentConfigs, Services and PersistentVolumeClaims for your Dockerized application.
If you need different kind of resources, use the 'kompose convert' and 'oc create -f' commands instead.

[36mINFO[0m Deploying application in "myproject" namespace
[36mINFO[0m Successfully created Service: frontend
[36mINFO[0m Successfully created DeploymentConfig: frontend
[36mINFO[0m Successfully created ImageStream: frontend

Your application has been deployed to OpenShift. You can run 'oc get dc,svc,is,pvc' for details.
PS C:\to_learn\docker-compose-to-minishift\first-try> oc expose service/frontend
route.route.openshift.io/frontend exposed
PS C:\to_learn\docker-compose-to-minishift\first-try> minishift openshift service frontend --namespace=myproject
|-----------|----------|----------------------|-------------------------------------------------|--------|
| NAMESPACE |   NAME   |       NODEPORT       |                    ROUTE-URL                    | WEIGHT |
|-----------|----------|----------------------|-------------------------------------------------|--------|
| myproject | frontend | 192.168.99.101:30215 | http://frontend-myproject.192.168.99.101.nip.io |        |
|-----------|----------|----------------------|-------------------------------------------------|--------|
PS C:\to_learn\docker-compose-to-minishift\first-try>

And when I try to open http://frontend-myproject.192.168.99.101.nip.io in Chrome:

Application is not available
The application is currently not serving requests at this endpoint. It may not have been started or is still starting.
...

Edited (trying deploying another sample application)

PS C:\to_learn\docker-compose-to-minishift\first-try>  nslookup x.127.0.0.1.xip.io
Servidor:  one.one.one.one
Address:  1.1.1.1

Não é resposta autoritativa:
Nome:    x.127.0.0.1.xip.io
Address:  127.0.0.1

PS C:\to_learn\docker-compose-to-minishift\first-try> oc version
oc v3.11.0+0cbc58b
kubernetes v1.11.0+d4cacc0
features: Basic-Auth SSPI Kerberos SPNEGO

Server https://192.168.99.101:8443
kubernetes v1.11.0+d4cacc0
PS C:\to_learn\docker-compose-to-minishift\first-try>  oc new-app --name='cotd' --labels name='cotd' php~https://github.com/devopswith-openshift/cotd.git -e SELECTOR=cats
--> Found image dc5aa55 (2 months old) in image stream "openshift/php" under tag "7.1" for "php"

    Apache 2.4 with PHP 7.1
    -----------------------
    PHP 7.1 available as container is a base platform for building and running various PHP 7.1 applications and frameworks. PHP is an HTML-embedded scripting language. PHP attempts to make it easy for developers to write dynamically generated web pages. PHP also offers built-in database integration for several commercial and non-commercial database management systems, so writing a database-enabled webpage with PHP is fairly simple. The most common use of PHP coding is probably as a replacement for CGI scripts.

    Tags: builder, php, php71, rh-php71

    * A source build using source code from https://github.com/devopswith-openshift/cotd.git will be created
      * The resulting image will be pushed to image stream tag "cotd:latest"
      * Use 'start-build' to trigger a new build
    * This image will be deployed in deployment config "cotd"
    * Ports 8080/tcp, 8443/tcp will be load balanced by service "cotd"
      * Other containers can access this service through the hostname "cotd"

--> Creating resources with label name=cotd ...
    imagestream.image.openshift.io "cotd" created
    buildconfig.build.openshift.io "cotd" created
    deploymentconfig.apps.openshift.io "cotd" created
    service "cotd" created
--> Success
    Build scheduled, use 'oc logs -f bc/cotd' to track its progress.
    Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
     'oc expose svc/cotd'
    Run 'oc status' to view your app.
PS C:\to_learn\docker-compose-to-minishift\first-try> oc expose svc/cotd
route.route.openshift.io/cotd exposed
PS C:\to_learn\docker-compose-to-minishift\first-try> oc status
In project myproject on server https://192.168.99.101:8443

http://cotd-myproject.192.168.99.101.nip.io to pod port 8080-tcp (svc/cotd)
  dc/cotd deploys istag/cotd:latest <-
    bc/cotd source builds https://github.com/devopswith-openshift/cotd.git on openshift/php:7.1
      build #1 pending for 11 minutes
    deployment #1 waiting on image or update

http://frontend-myproject.192.168.99.101.nip.io to pod port 8080 (svc/frontend)
  dc/frontend deploys istag/frontend:v4
    deployment #1 waiting on image or update


4 infos identified, use 'oc status --suggest' to see details.
PS C:\to_learn\docker-compose-to-minishift\first-try> oc status --suggest
In project myproject on server https://192.168.99.101:8443

http://cotd-myproject.192.168.99.101.nip.io to pod port 8080-tcp (svc/cotd)
  dc/cotd deploys istag/cotd:latest <-
    bc/cotd source builds https://github.com/devopswith-openshift/cotd.git on openshift/php:7.1
      build #1 pending for 12 minutes
    deployment #1 waiting on image or update

http://frontend-myproject.192.168.99.101.nip.io to pod port 8080 (svc/frontend)
  dc/frontend deploys istag/frontend:v4
    deployment #1 waiting on image or update

Info:
  * dc/cotd has no readiness probe to verify pods are ready to accept traffic or ensure deployment is successful.
    try: oc set probe dc/cotd --readiness ...
  * dc/cotd has no liveness probe to verify pods are still running.
    try: oc set probe dc/cotd --liveness ...
  * dc/frontend has no readiness probe to verify pods are ready to accept traffic or ensure deployment is successful.
    try: oc set probe dc/frontend --readiness ...
  * dc/frontend has no liveness probe to verify pods are still running.
    try: oc set probe dc/frontend --liveness ...

View details with 'oc describe <resource>/<name>' or list everything with 'oc get all'.
PS C:\to_learn\docker-compose-to-minishift\first-try>

Build Pending Status

cotd-myproject

Dehumanize answered 19/2, 2020 at 22:16 Comment(7)
Do you have an other services running on ports 80 and 8080? The error seems to me there's another processing using port 80. You can check using the command sudo netstat -ntpl. Please provide the output and the docker-compose yaml converted by kompose.Juneberry
Well, I only found TCP 192.168.218.45:54082 10.11.50.50:80 SYN_SENT. I added above all you asked forDehumanize
In case it is usefull: PS C:\to_learn\docker-compose-to-minishift\first-try> kubectl get deployment,svc,pods,pvc NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE service/frontend LoadBalancer 172.30.161.61 172.29.206.193,172.29.206.193 8080:30215/TCP 12mDehumanize
@rabello I tried deploying another sample application following each step carefully and I reched same issue. I will add above what I tried so far.Dehumanize
Well, I pasted above a weird message "Build #1 is pending". Does it gibe you some clue?Dehumanize
The errors seems you have another process running on port 80. Could you post the output of netstat -ab. Please see this link. Plus, try to change your service type to NodePort. If you want make sure you don't have anything running in port 80, stop your minishift system and try to access `localhost.Juneberry
Regarding "(13)Permission denied" - you cannot deploy containers with root user by default. Try docs.openshift.com/container-platform/3.11/admin_guide/… - or provide anyuid to default sa from projectDeutsch
P
7

It happens when you use a non-root container like bitnami official images.

We used user:root and network_mode: host when it needs to get bind with host network.

  apache:
    image: bitnami/apache:2.4
    container_name: "apache"
    ports:
      - 80:80
    network_mode: host
    privileged: true
    user: root
    environment:
      DOCKER_HOST: "unix:///var/run/docker.sock"
    env_file:
      - .env
    volumes:
      - ./setup/apache/httpd.conf:/opt/bitnami/apache/conf/httpd.conf
Phenyl answered 2/6, 2020 at 12:45 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.